Remove tests afterAll

This commit is contained in:
Zoe Roux 2025-01-28 12:41:20 +01:00
parent 7906374553
commit 740bf7adaa
No known key found for this signature in database
4 changed files with 8 additions and 26 deletions

View File

@ -1,5 +1,4 @@
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
import { eq } from "drizzle-orm";
import { beforeAll, describe, expect, it } from "bun:test";
import { expectStatus } from "tests/utils";
import { seedMovie } from "~/controllers/seed/movies";
import { db } from "~/db";
@ -7,15 +6,12 @@ import { shows } from "~/db/schema";
import { bubble } from "~/models/examples";
import { dune1984 } from "~/models/examples/dune-1984";
import { dune } from "~/models/examples/dune-2021";
import { createMovie, getMovies, app } from "../helper";
import { app, createMovie, getMovies } from "../helper";
beforeAll(async () => {
await db.delete(shows);
for (const movie of [bubble, dune1984, dune]) await seedMovie(movie);
});
afterAll(async () => {
await db.delete(shows);
});
describe("with a null value", () => {
// Those before/after hooks are NOT scopped to the describe due to a bun bug
@ -47,9 +43,6 @@ describe("with a null value", () => {
externalId: {},
});
});
afterAll(async () => {
await db.delete(shows).where(eq(shows.slug, "no-air-date"));
});
it("sort by dates desc with a null value", async () => {
let [resp, body] = await getMovies({

View File

@ -1,4 +1,4 @@
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
import { beforeAll, describe, expect, it } from "bun:test";
import { expectStatus } from "tests/utils";
import { seedMovie } from "~/controllers/seed/movies";
import { db } from "~/db";
@ -14,9 +14,6 @@ beforeAll(async () => {
await db.delete(shows);
for (const movie of [bubble, dune1984, dune]) await seedMovie(movie);
});
afterAll(async () => {
await db.delete(shows);
});
describe("Get all movies", () => {
it("Invalid filter params", async () => {

View File

@ -8,7 +8,7 @@ let bubbleId = "";
beforeAll(async () => {
const ret = await seedMovie(bubble);
if (ret.status !== 422) bubbleId = ret.id;
if (!("status" in ret)) bubbleId = ret.id;
});
describe("Get movie", () => {

View File

@ -1,14 +1,8 @@
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
import { beforeAll, describe, expect, it } from "bun:test";
import { eq } from "drizzle-orm";
import { expectStatus } from "tests/utils";
import { db } from "~/db";
import {
entries,
entryVideoJoin,
showTranslations,
shows,
videos,
} from "~/db/schema";
import { showTranslations, shows, videos } from "~/db/schema";
import { bubble } from "~/models/examples";
import { dune, duneVideo } from "~/models/examples/dune-2021";
import { createMovie, createVideo } from "../helper";
@ -388,6 +382,7 @@ describe("Movie seeding", () => {
},
]);
expectStatus(vresp, video).toBe(201);
console.log(video);
const [resp, body] = await createMovie({
...bubble,
@ -395,7 +390,7 @@ describe("Movie seeding", () => {
videos: [video[0].id, video[1].id],
});
expectStatus(resp, body).toBe(201);
console.log(body)
console.log(body);
const ret = await db.query.shows.findFirst({
where: eq(shows.id, body.id),
@ -415,10 +410,7 @@ describe("Movie seeding", () => {
const cleanup = async () => {
await db.delete(shows);
await db.delete(entries);
await db.delete(entryVideoJoin);
await db.delete(videos);
};
// cleanup db beforehand to unsure tests are consistent
beforeAll(cleanup);
afterAll(cleanup);