feat: Pin to home (#2880)
This commit is contained in:
38
server/commands/pinDestroyer.test.ts
Normal file
38
server/commands/pinDestroyer.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Pin, Event } from "@server/models";
|
||||
import { buildDocument, buildUser } from "@server/test/factories";
|
||||
import { flushdb } from "@server/test/support";
|
||||
import pinDestroyer from "./pinDestroyer";
|
||||
|
||||
beforeEach(() => flushdb());
|
||||
describe("pinCreator", () => {
|
||||
const ip = "127.0.0.1";
|
||||
|
||||
it("should destroy existing pin", async () => {
|
||||
const user = await buildUser();
|
||||
const document = await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
});
|
||||
|
||||
const pin = await Pin.create({
|
||||
teamId: document.teamId,
|
||||
documentId: document.id,
|
||||
collectionId: document.collectionId,
|
||||
createdById: user.id,
|
||||
index: "P",
|
||||
});
|
||||
|
||||
await pinDestroyer({
|
||||
pin,
|
||||
user,
|
||||
ip,
|
||||
});
|
||||
|
||||
const count = await Pin.count();
|
||||
expect(count).toEqual(0);
|
||||
|
||||
const event = await Event.findOne();
|
||||
expect(event.name).toEqual("pins.delete");
|
||||
expect(event.modelId).toEqual(pin.id);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user