mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
|
|
||
|
import * as sinon from "sinon";
|
||
|
import * as assert from "assert";
|
||
|
import { FileSystemNotifier } from "../../../src/lib/notifiers/FileSystemNotifier";
|
||
|
import * as tmp from "tmp";
|
||
|
import * as fs from "fs";
|
||
|
|
||
|
const NOTIFICATIONS_DIRECTORY = "notifications";
|
||
|
|
||
|
describe("test FS notifier", function() {
|
||
|
let tmpDir: tmp.SynchrounousResult;
|
||
|
before(function() {
|
||
|
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
||
|
});
|
||
|
|
||
|
after(function() {
|
||
|
tmpDir.removeCallback();
|
||
|
});
|
||
|
|
||
|
it("should write the notification in a file", function() {
|
||
|
const options = {
|
||
|
filename: tmpDir.name + "/" + NOTIFICATIONS_DIRECTORY
|
||
|
};
|
||
|
|
||
|
const sender = new FileSystemNotifier(options);
|
||
|
const subject = "subject";
|
||
|
|
||
|
const identity = {
|
||
|
userid: "user",
|
||
|
email: "user@example.com"
|
||
|
};
|
||
|
|
||
|
const url = "http://test.com";
|
||
|
|
||
|
return sender.notify(identity, subject, url)
|
||
|
.then(function() {
|
||
|
const content = fs.readFileSync(options.filename, "UTF-8");
|
||
|
assert(content.length > 0);
|
||
|
return Promise.resolve();
|
||
|
});
|
||
|
});
|
||
|
});
|