Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
hokaccha committed Mar 25, 2024
1 parent 04a2ad2 commit 259d0d7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/cleaner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ describe("PrismaCleaner", () => {
expect(await prisma.user.count()).toBe(0);
});

test("with transaction", async () => {
await prisma.$transaction(async (client) => {
await client.user.create({
data: {
name: "foo",
},
});
await client.user.create({
data: {
name: "bar",
},
});
});
expect(await prisma.user.count()).toBe(2);

await cleaner.cleanup();
expect(await prisma.user.count()).toBe(0);
});

test("manually cleanup", async () => {
const insert = () =>
prisma.$executeRaw`insert into "User" (name) values ('xxx')`;
Expand Down

0 comments on commit 259d0d7

Please sign in to comment.