authelia/server/test/notifiers/NotifierFactory.test.ts

45 lines
1.4 KiB
TypeScript
Raw Normal View History

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 { SmtpNotifier } from "../../src/lib/notifiers/SmtpNotifier";
2017-05-20 07:49:05 +00:00
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-09-24 18:55:11 +00:00
const transporterMock = NodemailerMock.NodemailerTransporterMock();
nodemailerMock.createTransport.returns(transporterMock);
2017-05-20 20:55:37 +00:00
assert(NotifierFactory.build(options, nodemailerMock) instanceof GMailNotifier);
2017-05-20 07:49:05 +00:00
});
2017-09-24 18:55:11 +00:00
it("should build a SMTP Notifier", function() {
2017-05-20 07:49:05 +00:00
const options = {
2017-09-24 18:55:11 +00:00
smtp: {
username: "user",
password: "pass",
secure: true,
host: "localhost",
port: 25
2017-05-20 07:49:05 +00:00
}
};
2017-09-24 18:55:11 +00:00
nodemailerMock = NodemailerMock.NodemailerMock();
const transporterMock = NodemailerMock.NodemailerTransporterMock();
nodemailerMock.createTransport.returns(transporterMock);
assert(NotifierFactory.build(options, nodemailerMock) instanceof SmtpNotifier);
2017-05-20 07:49:05 +00:00
});
});