Files
outline/server/commands/starDestroyer.test.ts
Tom Moor 79e2cad5b9 feat: Add reordering to starred documents (#2953)
* draft

* reordering

* JIT Index stars on first load

* test

* Remove unused code on client

* small unrefactor
2022-01-21 18:11:50 -08:00

40 lines
947 B
TypeScript

import { Star, Event } from "@server/models";
import { buildDocument, buildUser } from "@server/test/factories";
import { flushdb } from "@server/test/support";
import starDestroyer from "./starDestroyer";
beforeEach(() => flushdb());
describe("starDestroyer", () => {
const ip = "127.0.0.1";
it("should destroy existing star", async () => {
const user = await buildUser();
const document = await buildDocument({
userId: user.id,
teamId: user.teamId,
});
const star = await Star.create({
teamId: document.teamId,
documentId: document.id,
userId: user.id,
createdById: user.id,
index: "P",
});
await starDestroyer({
star,
user,
ip,
});
const count = await Star.count();
expect(count).toEqual(0);
const event = await Event.findOne();
expect(event!.name).toEqual("stars.delete");
expect(event!.modelId).toEqual(star.id);
});
});