32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "@jest/globals";
|
|
import { Mailbox } from '../src/mailer_framework';
|
|
|
|
describe('Mailer Framework Test', () =>
|
|
{
|
|
let mailbox: Mailbox = new Mailbox({host: "", port: 0}, {host: "", port: 0}, "");
|
|
test('Should only have one mailing list', () => {
|
|
mailbox.addMailingList("test1", ["sample@gmail.com"]);
|
|
expect(mailbox.getEmails("test1")).toMatchObject(["sample@gmail.com"]);
|
|
});
|
|
test("Mailing list corruption", () =>
|
|
{
|
|
// Make sure the first one does not change.
|
|
mailbox.addMailingList("test2", ["sample@gmail.com", "sample2@gmail.com"]);
|
|
expect(mailbox.getEmails("test1")).toMatchObject(["sample@gmail.com"]);
|
|
expect(mailbox.getEmails("test2")).toMatchObject(["sample@gmail.com", "sample2@gmail.com"]);
|
|
});
|
|
test("Deregistration test", () =>
|
|
{
|
|
// Make sure the first one does not change.
|
|
mailbox.unregisterEmailFromAll("sample@gmail.com");
|
|
expect(mailbox.getEmails("test1")).toMatchObject([]);
|
|
expect(mailbox.getEmails("test2")).toMatchObject(["sample2@gmail.com"]);
|
|
});
|
|
test("Existing registration test", () =>
|
|
{
|
|
// Make sure the first one does not change.
|
|
mailbox.registerEmail("sample3@gmail.com", "test1");
|
|
expect(mailbox.getEmails("test1")).toMatchObject(["sample3@gmail.com"]);
|
|
expect(mailbox.getEmails("test2")).toMatchObject(["sample2@gmail.com"]);
|
|
});
|
|
}); |