2017-05-20 07:49:05 +00:00
|
|
|
|
|
|
|
import * as sinon from "sinon";
|
|
|
|
import * as BluebirdPromise from "bluebird";
|
|
|
|
import * as assert from "assert";
|
|
|
|
|
|
|
|
import { NotifierFactory } from "../../../src/lib/notifiers/NotifierFactory";
|
|
|
|
import { GMailNotifier } from "../../../src/lib/notifiers/GMailNotifier";
|
|
|
|
import { FileSystemNotifier } from "../../../src/lib/notifiers/FileSystemNotifier";
|
|
|
|
|
2017-05-21 20:45:54 +00:00
|
|
|
import NodemailerMock = require("../mocks/nodemailer");
|
2017-05-20 07:49:05 +00:00
|
|
|
|
|
|
|
|
2017-05-20 20:55:37 +00:00
|
|
|
describe("test notifier factory", function() {
|
2017-05-21 20:45:54 +00:00
|
|
|
let nodemailerMock: NodemailerMock.NodemailerMock;
|
2017-05-20 07:49:05 +00:00
|
|
|
it("should build a Gmail Notifier", function() {
|
|
|
|
const options = {
|
|
|
|
gmail: {
|
|
|
|
username: "abc",
|
|
|
|
password: "password"
|
|
|
|
}
|
|
|
|
};
|
2017-05-21 20:45:54 +00:00
|
|
|
nodemailerMock = NodemailerMock.NodemailerMock();
|
2017-05-20 20:55:37 +00:00
|
|
|
nodemailerMock.createTransport.returns(sinon.spy());
|
|
|
|
assert(NotifierFactory.build(options, nodemailerMock) instanceof GMailNotifier);
|
2017-05-20 07:49:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should build a FS Notifier", function() {
|
|
|
|
const options = {
|
|
|
|
filesystem: {
|
|
|
|
filename: "abc"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-20 20:55:37 +00:00
|
|
|
assert(NotifierFactory.build(options, nodemailerMock) instanceof FileSystemNotifier);
|
2017-05-20 07:49:05 +00:00
|
|
|
});
|
|
|
|
});
|