Files
outline/server/queues/processors/RevisionsProcessor.test.ts
Tom Moor 1fbc000e03 chore: Reduce test boilerplate (#4300)
* chore: Reduce test boilerplate

* mo
2022-10-15 19:40:21 -07:00

56 lines
1.6 KiB
TypeScript

import { Revision } from "@server/models";
import { buildDocument } from "@server/test/factories";
import { setupTestDatabase } from "@server/test/support";
import RevisionsProcessor from "./RevisionsProcessor";
const ip = "127.0.0.1";
setupTestDatabase();
describe("documents.update.debounced", () => {
test("should create a revision", async () => {
const document = await buildDocument();
const processor = new RevisionsProcessor();
await processor.perform({
name: "documents.update.debounced",
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
actorId: document.createdById,
createdAt: new Date().toISOString(),
data: { title: document.title, autosave: false, done: true },
ip,
});
const amount = await Revision.count({
where: {
documentId: document.id,
},
});
expect(amount).toBe(1);
});
test("should not create a revision if identical to previous", async () => {
const document = await buildDocument();
await Revision.createFromDocument(document);
const processor = new RevisionsProcessor();
await processor.perform({
name: "documents.update.debounced",
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
actorId: document.createdById,
createdAt: new Date().toISOString(),
data: { title: document.title, autosave: false, done: true },
ip,
});
const amount = await Revision.count({
where: {
documentId: document.id,
},
});
expect(amount).toBe(1);
});
});