mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-11 19:02:16 +02:00
Update mocks for utils in tests
This commit is contained in:
parent
bd76a63964
commit
82b435b290
@ -2,7 +2,7 @@ import type { AccountInfoResponse } from "#app/@types/PokerogueAccountApi";
|
|||||||
import { SESSION_ID_COOKIE_NAME } from "#app/constants";
|
import { SESSION_ID_COOKIE_NAME } from "#app/constants";
|
||||||
import { PokerogueAccountApi } from "#app/plugins/api/pokerogue-account-api";
|
import { PokerogueAccountApi } from "#app/plugins/api/pokerogue-account-api";
|
||||||
import { getApiBaseUrl } from "#test/testUtils/testUtils";
|
import { getApiBaseUrl } from "#test/testUtils/testUtils";
|
||||||
import * as Utils from "#app/utils/common";
|
import * as CookieUtils from "#app/utils/cookies";
|
||||||
import * as cookies from "#app/utils/cookies";
|
import * as cookies from "#app/utils/cookies";
|
||||||
import { http, HttpResponse } from "msw";
|
import { http, HttpResponse } from "msw";
|
||||||
import { beforeAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
import { beforeAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
@ -99,7 +99,7 @@ describe("Pokerogue Account API", () => {
|
|||||||
const loginParams = { username: "test", password: "test" };
|
const loginParams = { username: "test", password: "test" };
|
||||||
|
|
||||||
it("should return null and set the cookie on SUCCESS", async () => {
|
it("should return null and set the cookie on SUCCESS", async () => {
|
||||||
vi.spyOn(Utils, "setCookie");
|
vi.spyOn(CookieUtils, "setCookie");
|
||||||
server.use(http.post(`${apiBase}/account/login`, () => HttpResponse.json({ token: "abctest" })));
|
server.use(http.post(`${apiBase}/account/login`, () => HttpResponse.json({ token: "abctest" })));
|
||||||
|
|
||||||
const error = await accountApi.login(loginParams);
|
const error = await accountApi.login(loginParams);
|
||||||
@ -131,11 +131,11 @@ describe("Pokerogue Account API", () => {
|
|||||||
|
|
||||||
describe("Logout", () => {
|
describe("Logout", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.spyOn(Utils, "removeCookie");
|
vi.spyOn(CookieUtils, "removeCookie");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should remove cookie on success", async () => {
|
it("should remove cookie on success", async () => {
|
||||||
vi.spyOn(Utils, "setCookie");
|
vi.spyOn(CookieUtils, "setCookie");
|
||||||
server.use(http.get(`${apiBase}/account/logout`, () => new HttpResponse("", { status: 200 })));
|
server.use(http.get(`${apiBase}/account/logout`, () => new HttpResponse("", { status: 200 })));
|
||||||
|
|
||||||
await accountApi.logout();
|
await accountApi.logout();
|
||||||
|
Loading…
Reference in New Issue
Block a user