mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-20 03:55:51 +02:00
* start migrating Utils.apiFetch to api class
* move dailyranking to api
* use api in title-ui-handler
* remove: Utils.apiFetch
* migrate `updateSystemSavedata` to api
* migrate clear session savedata to api
* migrate updateAllSavedata to api
* migrate `updateSessionSavedata` to api
* rename `api` to `pokerogue-api`
* migrate unlink discord to pokerogue-api
* migrate unlink google to pokerogue-api
* update pokerogue-api login
* migrate register account to pokerogue-api
* remove Utils.apiPost
* reset overrides.ts
* chore: cleanup
* fix env.development
* fix circular dependencies with api
* fix gamedata verify missing await
* fix daily api calls in daily-run-scorebard
* fix discord-link request body being empty
there was a double `toUrlSearchParams()` call involved
* add pokerogue-api test coverge
* add test-utils `getApiBaseUrl()` method
* add pokerogue-admin-api test coverage
* add pokerogue-account-api test coverage
* add pokerogue-daily-api test coverage
* add pokerogue-savedata-api test coverage
* fix some test describes
* add pokerogue-session-savedata-api test coverage
* add pokerogue-system-savedata-api test coverage
* fix tests
* fix tryExportData
thanks @MokaStitcher
* chore: fix menu-ui-handlers.ts
* fix admin-ui-handler (types)
* extend test-coverage for admin-api
* remove outdated code
* skip some clowning-around-encounter tests if events are active
this is not a permanent solution
* Update src/system/game-data.ts
Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>
* Revert "skip some clowning-around-encounter tests if events are active"
This reverts commit a97dafe8b2
.
* mark `localServerUrl` and `apiUrl` as deprecated
in `utils.ts`
---------
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>
80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
// import { apiFetch } from "#app/utils";
|
|
import GameManager from "#test/utils/gameManager";
|
|
import { waitUntil } from "#test/utils/gameManagerUtils";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
describe("Test misc", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
});
|
|
|
|
it("test fetch mock async", async () => {
|
|
const spy = vi.fn();
|
|
await fetch("https://localhost:8080/account/info").then(response => {
|
|
expect(response.status).toBe(200);
|
|
expect(response.ok).toBe(true);
|
|
return response.json();
|
|
}).then(data => {
|
|
spy(); // Call the spy function
|
|
expect(data).toEqual({ "username": "greenlamp", "lastSessionSlot": 0 });
|
|
});
|
|
expect(spy).toHaveBeenCalled();
|
|
});
|
|
|
|
// it.skip("test apifetch mock async", async () => {
|
|
// const spy = vi.fn();
|
|
// await apiFetch("https://localhost:8080/account/info").then(response => {
|
|
// expect(response.status).toBe(200);
|
|
// expect(response.ok).toBe(true);
|
|
// return response.json();
|
|
// }).then(data => {
|
|
// spy(); // Call the spy function
|
|
// expect(data).toEqual({ "username": "greenlamp", "lastSessionSlot": 0 });
|
|
// });
|
|
// expect(spy).toHaveBeenCalled();
|
|
// });
|
|
|
|
it("test fetch mock sync", async () => {
|
|
const response = await fetch("https://localhost:8080/account/info");
|
|
const data = await response.json();
|
|
|
|
expect(response.ok).toBe(true);
|
|
expect(response.status).toBe(200);
|
|
expect(data).toEqual({ "username": "greenlamp", "lastSessionSlot": 0 });
|
|
});
|
|
|
|
it("test apifetch mock sync", async () => {
|
|
const data = await game.scene.cachedFetch("./battle-anims/splishy-splash.json");
|
|
expect(data).toBeDefined();
|
|
});
|
|
|
|
it("testing wait phase queue", async () => {
|
|
const fakeScene = {
|
|
phaseQueue: [ 1, 2, 3 ] // Initially not empty
|
|
};
|
|
setTimeout(() => {
|
|
fakeScene.phaseQueue = [];
|
|
}, 500);
|
|
const spy = vi.fn();
|
|
await waitUntil(() => fakeScene.phaseQueue.length === 0).then(result => {
|
|
expect(result).toBe(true);
|
|
spy(); // Call the spy function
|
|
});
|
|
expect(spy).toHaveBeenCalled();
|
|
});
|
|
});
|