mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 06:15:39 -04:00
test(core): replace image-cache module mocks with globalThis.fetch spies
Switch `mock.module("../src/image-cache", ...)` stubs in thumbhash, person-detail, colors, and credits tests to `spyOn(globalThis, "fetch")` instead. This avoids the cross-file persistence problem with `mock.module` and tests the real code paths more faithfully.
Update `image-cache.ts` to call `globalThis.fetch` so the spy intercepts it, add `mock.restore()` to the global `afterEach` in `preload.ts`, and set `IMAGE_CACHE_ENABLED=false` in affected tests to avoid disk writes during test runs.
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
||||
import { beforeEach, describe, expect, test } from "bun:test";
|
||||
import { persons, titleCast } from "@sofa/db/schema";
|
||||
import { clearAllTables, insertTitle, testDb } from "@sofa/db/test-utils";
|
||||
|
||||
mock.module("../src/image-cache", () => ({
|
||||
imageCacheEnabled: () => false,
|
||||
cacheProfilePhotos: async () => {},
|
||||
}));
|
||||
|
||||
import { getCastForTitle } from "../src/credits";
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user