mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-12-01 11:16:21 +00:00
add test-utils getApiBaseUrl()
method
This commit is contained in:
parent
17d44dd125
commit
f474ec0b6b
@ -1,10 +1,11 @@
|
||||
import type { TitleStatsResponse } from "#app/@types/PokerogueApi";
|
||||
import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
|
||||
import { getApiBaseUrl } from "#app/test/utils/testUtils";
|
||||
import { http, HttpResponse } from "msw";
|
||||
import { setupServer } from "msw/node";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const apiBase = import.meta.env.VITE_API_BASE_URL ?? "http://localhost:8001";
|
||||
const apiBase = getApiBaseUrl();
|
||||
const server = setupServer();
|
||||
|
||||
beforeAll(() => {
|
||||
@ -84,7 +85,6 @@ describe("Pokerogue API", () => {
|
||||
expect(success).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
it("should return false and report a warning on FAILURE", async () => {
|
||||
server.use(http.post(`${apiBase}/auth/google/logout`, () => new HttpResponse("", { status: 401 })));
|
||||
|
||||
|
@ -21,3 +21,11 @@ export function mockI18next() {
|
||||
export function arrayOfRange(start: integer, end: integer) {
|
||||
return Array.from({ length: end - start }, (_v, k) => k + start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to get the API base URL from the environment variable (or the default/fallback).
|
||||
* @returns the API base URL
|
||||
*/
|
||||
export function getApiBaseUrl() {
|
||||
return import.meta.env.VITE_SERVER_URL ?? "http://localhost:8001";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user