test: preload mocked modules

This commit is contained in:
2024-06-15 06:24:29 -04:00
parent d39165c8f6
commit dfd709ad1c
5 changed files with 30 additions and 37 deletions

View File

@@ -1,2 +1,2 @@
[test] [test]
preload = ["./testSetup.ts"] preload = ["./testSetup.ts", "./src/mocks/consumet.ts", "./src/mocks/gToken.ts"]

View File

@@ -2,10 +2,8 @@ import { describe, expect, it } from "bun:test";
import app from "~/index"; import app from "~/index";
import { server } from "~/mocks"; import { server } from "~/mocks";
import { mockConsumet } from "~/mocks/consumet";
server.listen(); server.listen();
mockConsumet();
describe('requests the "/episodes" route', () => { describe('requests the "/episodes" route', () => {
it("with list of episodes from Anify", async () => { it("with list of episodes from Anify", async () => {

View File

@@ -2,10 +2,8 @@ import { describe, expect, it } from "bun:test";
import app from "~/index"; import app from "~/index";
import { server } from "~/mocks"; import { server } from "~/mocks";
import { mockConsumet } from "~/mocks/consumet";
server.listen(); server.listen();
mockConsumet();
describe('requests the "/episodes/:id/url" route', () => { describe('requests the "/episodes/:id/url" route', () => {
it("with sources from Anify", async () => { it("with sources from Anify", async () => {

View File

@@ -1,7 +1,6 @@
import { describe, expect, it } from "bun:test"; import { describe, expect, it } from "bun:test";
import { server } from "~/mocks"; import { server } from "~/mocks";
import "~/mocks/gToken";
import { verifyFcmToken } from "./verifyFcmToken"; import { verifyFcmToken } from "./verifyFcmToken";

View File

@@ -2,8 +2,7 @@ import type { IAnimeEpisode, ISource } from "@consumet/extensions";
import { mock } from "bun:test"; import { mock } from "bun:test";
export function mockConsumet() { mock.module("src/consumet", () => ({
mock.module("src/consumet", () => ({
aniList: { aniList: {
fetchEpisodesListById( fetchEpisodesListById(
id: string, id: string,
@@ -33,5 +32,4 @@ export function mockConsumet() {
}); });
}, },
}, },
})); }));
}