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