Files
outline/server/queues/tasks/InviteReminderTask.test.ts
Tom Moor 45831e9469 Remove NotificationSettings table (#5036
* helper

* Add script to move notification settings

* wip, removal of NotificationSettings

* event name

* iteration

* test

* test

* Remove last of NotificationSettings model

* refactor

* More fixes

* snapshots

* Change emails to class instances for type safety

* test

* docs

* Update migration for self-hosted

* tsc
2023-03-18 06:32:41 -07:00

38 lines
986 B
TypeScript

import { subDays } from "date-fns";
import InviteReminderEmail from "@server/emails/templates/InviteReminderEmail";
import { buildInvite } from "@server/test/factories";
import { setupTestDatabase } from "@server/test/support";
import InviteReminderTask from "./InviteReminderTask";
setupTestDatabase();
describe("InviteReminderTask", () => {
it("should not destroy documents not deleted", async () => {
const spy = jest.spyOn(InviteReminderEmail.prototype, "schedule");
// too old
await buildInvite({
createdAt: subDays(new Date(), 3.5),
});
// too new
await buildInvite({
createdAt: new Date(),
});
// should send reminder
await buildInvite({
createdAt: subDays(new Date(), 2.5),
});
const task = new InviteReminderTask();
await task.perform();
// running twice to make sure the email is only sent once
await task.perform();
expect(spy).toHaveBeenCalledTimes(1);
spy.mockRestore();
});
});