mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-15 06:15:20 +01:00
[Tests] Cleaned up cachedFetch test stub
This commit is contained in:
parent
41b2f2f4fc
commit
ab2d5bcfb5
@ -182,21 +182,16 @@ export class GameWrapper {
|
||||
this.scene.scene = this.scene;
|
||||
this.scene.input.keyboard = new KeyboardPlugin(this.scene);
|
||||
this.scene.input.gamepad = new GamepadPlugin(this.scene);
|
||||
this.scene.cachedFetch = (url, _init) => {
|
||||
return new Promise(resolve => {
|
||||
// need to remove that if later we want to test battle-anims
|
||||
const newUrl = url.includes("./battle-anims/") ? prependPath("./battle-anims/tackle.json") : prependPath(url);
|
||||
// biome-ignore lint/suspicious/noImplicitAnyLet: TODO
|
||||
let raw;
|
||||
try {
|
||||
raw = fs.readFileSync(newUrl, { encoding: "utf8", flag: "r" });
|
||||
} catch (_e) {
|
||||
return resolve(createFetchBadResponse({}));
|
||||
}
|
||||
const data = JSON.parse(raw);
|
||||
const response = createFetchResponse(data);
|
||||
return resolve(response);
|
||||
});
|
||||
this.scene.cachedFetch = async (url, _init): Promise<Response> => {
|
||||
// Replace all battle anim fetches solely with the tackle anim to save time.
|
||||
// TODO: This effectively bars us from testing battle animation related code ever
|
||||
const newUrl = url.includes("./battle-anims/") ? prependPath("./battle-anims/tackle.json") : prependPath(url);
|
||||
try {
|
||||
const raw = fs.readFileSync(newUrl, { encoding: "utf8", flag: "r" });
|
||||
return createFetchResponse(JSON.parse(raw));
|
||||
} catch {
|
||||
return createFetchBadResponse({});
|
||||
}
|
||||
};
|
||||
this.scene.make = new MockGameObjectCreator(mockTextureManager);
|
||||
this.scene.time = new MockClock(this.scene);
|
||||
@ -213,7 +208,7 @@ function prependPath(originalPath) {
|
||||
return originalPath;
|
||||
}
|
||||
// Simulate fetch response
|
||||
function createFetchResponse(data) {
|
||||
function createFetchResponse(data: unknown): Response {
|
||||
return {
|
||||
ok: true,
|
||||
status: 200,
|
||||
@ -223,7 +218,7 @@ function createFetchResponse(data) {
|
||||
};
|
||||
}
|
||||
// Simulate fetch response
|
||||
function createFetchBadResponse(data) {
|
||||
function createFetchBadResponse(data: unknown): Response {
|
||||
return {
|
||||
ok: false,
|
||||
status: 404,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user