refactor: refactor foundation
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { HttpResponse, http } from "msw";
|
||||
|
||||
const authentication = {
|
||||
accessToken: "test-token",
|
||||
user: { id: "user-1", email: "user@example.com" },
|
||||
};
|
||||
|
||||
export const handlers = [
|
||||
http.post("*/api/v1/auth/register", () => HttpResponse.json(authentication)),
|
||||
http.post("*/api/v1/auth/login", () => HttpResponse.json(authentication)),
|
||||
http.post("*/api/v1/auth/refresh", () =>
|
||||
HttpResponse.json({ code: "UNAUTHORIZED" }, { status: 401 }),
|
||||
),
|
||||
http.post(
|
||||
"*/api/v1/auth/logout",
|
||||
() => new HttpResponse(null, { status: 204 }),
|
||||
),
|
||||
http.get("*/api/v1/auth/me", () => HttpResponse.json(authentication.user)),
|
||||
http.get("*/api/v1/tbank-connection", () =>
|
||||
HttpResponse.json({ connected: false, connectedAt: null }),
|
||||
),
|
||||
http.put("*/api/v1/tbank-connection", () =>
|
||||
HttpResponse.json({ connected: true, connectedAt: "2026-08-14T00:00:00Z" }),
|
||||
),
|
||||
http.delete(
|
||||
"*/api/v1/tbank-connection",
|
||||
() => new HttpResponse(null, { status: 204 }),
|
||||
),
|
||||
http.get("*/api/v1/brokerage-accounts", () => HttpResponse.json([])),
|
||||
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
|
||||
HttpResponse.json({
|
||||
lastSuccessfulAt: "2026-08-14T00:00:00Z",
|
||||
isStale: false,
|
||||
totalsByCurrency: [],
|
||||
positions: [],
|
||||
cashBalances: [],
|
||||
}),
|
||||
),
|
||||
];
|
||||
@@ -0,0 +1,4 @@
|
||||
import { setupServer } from "msw/node";
|
||||
import { handlers } from "./handlers";
|
||||
|
||||
export const server = setupServer(...handlers);
|
||||
@@ -1,5 +1,11 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { afterAll, afterEach, beforeAll } from "vitest";
|
||||
import "../shared/i18n";
|
||||
import { server } from "./server";
|
||||
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
Object.defineProperty(window, "matchMedia", {
|
||||
writable: true,
|
||||
|
||||
Reference in New Issue
Block a user