Skip to content

Commit

Permalink
what if promise.all fixes it?
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Nov 12, 2023
1 parent 89fa7c5 commit 867a2bc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/database/tests/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ describe("database integration tests", () => {
});

it("should disallow files with the same folder and filename", async () => {
await FileRepository.insertFile(db, aMockFileWith({ folder: "folder", name: "name" }));
await FileRepository.insertFile(db, aMockFileWith({ folder: "folder", name: "different_name" }));
await FileRepository.insertFile(db, aMockFileWith({ folder: "different_folder", name: "name" }));
await Promise.all([
FileRepository.insertFile(db, aMockFileWith({ folder: "folder", name: "name" })),
FileRepository.insertFile(db, aMockFileWith({ folder: "folder", name: "different_name" })),
FileRepository.insertFile(db, aMockFileWith({ folder: "different_folder", name: "name" })),
]);

expect(await getRowCount(db, "file")).toEqual(3);

Expand Down Expand Up @@ -64,8 +66,10 @@ describe("database integration tests", () => {

it("should disallow adding the same player for the same game", async () => {
const { gameId } = await addMockGame();
await PlayerRepository.insertPlayer(db, aMockPlayerWith(gameId, { index: 0 }));
await PlayerRepository.insertPlayer(db, aMockPlayerWith(gameId, { index: 1 }));
await Promise.all([
PlayerRepository.insertPlayer(db, aMockPlayerWith(gameId, { index: 0 })),
PlayerRepository.insertPlayer(db, aMockPlayerWith(gameId, { index: 1 })),
]);
expect(await getRowCount(db, "player")).toEqual(2);

const action = async () => await PlayerRepository.insertPlayer(db, aMockPlayerWith(gameId, { index: 1 }));
Expand Down

0 comments on commit 867a2bc

Please sign in to comment.