feat(ai-character): Mock Preview 모드 구현
This commit is contained in:
29
src/shared/mocks/browser.test.ts
Normal file
29
src/shared/mocks/browser.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
|
||||
const { setupWorkerMock, workerStart } = vi.hoisted(() => {
|
||||
const workerStart = vi.fn();
|
||||
const setupWorkerMock = vi.fn(() => ({ start: workerStart }));
|
||||
|
||||
return { setupWorkerMock, workerStart };
|
||||
});
|
||||
|
||||
vi.mock("msw/browser", () => ({
|
||||
setupWorker: setupWorkerMock,
|
||||
}));
|
||||
|
||||
import { startMockWorker } from "./browser";
|
||||
|
||||
describe("startMockWorker", () => {
|
||||
test("starts browser MSW with an error policy for unhandled requests", async () => {
|
||||
// Given
|
||||
vi.stubEnv("VITE_API_BASE_URL", "https://api.example.com");
|
||||
const startOptions = { onUnhandledRequest: "error" };
|
||||
|
||||
// When
|
||||
await startMockWorker();
|
||||
|
||||
// Then
|
||||
expect(setupWorkerMock).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything());
|
||||
expect(workerStart).toHaveBeenCalledWith(startOptions);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user