This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously. closes #1282
29 lines
898 B
TypeScript
29 lines
898 B
TypeScript
import { Event } from "@server/models";
|
|
import { buildDocument, buildUser } from "@server/test/factories";
|
|
import { flushdb } from "@server/test/support";
|
|
import revisionCreator from "./revisionCreator";
|
|
|
|
beforeEach(() => flushdb());
|
|
describe("revisionCreator", () => {
|
|
const ip = "127.0.0.1";
|
|
|
|
it("should create revision model from document", async () => {
|
|
const user = await buildUser();
|
|
const document = await buildDocument({
|
|
userId: user.id,
|
|
teamId: user.teamId,
|
|
});
|
|
const revision = await revisionCreator({
|
|
document,
|
|
user,
|
|
ip,
|
|
});
|
|
const event = await Event.findOne();
|
|
expect(revision.documentId).toEqual(document.id);
|
|
expect(revision.userId).toEqual(user.id);
|
|
expect(event.name).toEqual("revisions.create");
|
|
expect(event.modelId).toEqual(revision.id);
|
|
expect(event.createdAt).toEqual(document.updatedAt);
|
|
});
|
|
});
|