2017-05-20 14:49:05 +07:00
|
|
|
|
|
|
|
import * as sinon from "sinon";
|
|
|
|
import * as BluebirdPromise from "bluebird";
|
|
|
|
import * as assert from "assert";
|
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
import { NotifierFactory } from "../../src/lib/notifiers/NotifierFactory";
|
2017-10-25 15:28:56 +07:00
|
|
|
import { EMailNotifier } from "../../src/lib/notifiers/EMailNotifier";
|
2017-10-07 05:09:42 +07:00
|
|
|
import { SmtpNotifier } from "../../src/lib/notifiers/SmtpNotifier";
|
2017-10-08 05:46:57 +07:00
|
|
|
import { MailSenderBuilderStub } from "../mocks/notifiers/MailSenderBuilderStub";
|
2017-05-20 14:49:05 +07:00
|
|
|
|
|
|
|
|
2017-10-08 05:46:57 +07:00
|
|
|
describe("test notifier factory", function () {
|
|
|
|
let mailSenderBuilderStub: MailSenderBuilderStub;
|
2017-10-25 15:28:56 +07:00
|
|
|
it("should build a Email Notifier", function () {
|
2017-05-20 14:49:05 +07:00
|
|
|
const options = {
|
2017-10-25 15:28:56 +07:00
|
|
|
email: {
|
2017-05-20 14:49:05 +07:00
|
|
|
username: "abc",
|
2017-10-10 05:07:12 +07:00
|
|
|
password: "password",
|
2017-10-25 15:28:56 +07:00
|
|
|
sender: "admin@example.com",
|
|
|
|
service: "gmail"
|
2017-05-20 14:49:05 +07:00
|
|
|
}
|
|
|
|
};
|
2017-10-08 05:46:57 +07:00
|
|
|
mailSenderBuilderStub = new MailSenderBuilderStub();
|
2017-10-25 15:28:56 +07:00
|
|
|
assert(NotifierFactory.build(options, mailSenderBuilderStub) instanceof EMailNotifier);
|
2017-05-20 14:49:05 +07:00
|
|
|
});
|
|
|
|
|
2017-10-08 05:46:57 +07:00
|
|
|
it("should build a SMTP Notifier", function () {
|
2017-05-20 14:49:05 +07:00
|
|
|
const options = {
|
2017-09-25 01:55:11 +07:00
|
|
|
smtp: {
|
|
|
|
username: "user",
|
|
|
|
password: "pass",
|
|
|
|
secure: true,
|
|
|
|
host: "localhost",
|
2017-10-10 05:07:12 +07:00
|
|
|
port: 25,
|
|
|
|
sender: "admin@example.com"
|
2017-05-20 14:49:05 +07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-10-08 05:46:57 +07:00
|
|
|
mailSenderBuilderStub = new MailSenderBuilderStub();
|
|
|
|
assert(NotifierFactory.build(options, mailSenderBuilderStub) instanceof SmtpNotifier);
|
2017-05-20 14:49:05 +07:00
|
|
|
});
|
|
|
|
});
|