this repo has no description
1import "@testing-library/jest-dom/vitest";
2import { afterEach, beforeEach, vi } from "vitest";
3import { init, register, waitLocale } from "svelte-i18n";
4import { _testResetState } from "../lib/auth.svelte";
5
6register("en", () => import("../locales/en.json"));
7
8init({
9 fallbackLocale: "en",
10 initialLocale: "en",
11});
12
13let locationHash = "";
14
15Object.defineProperty(window, "location", {
16 value: {
17 get hash() {
18 return locationHash;
19 },
20 set hash(value: string) {
21 locationHash = value.startsWith("#") ? value : `#${value}`;
22 },
23 href: "http://localhost:3000/",
24 origin: "http://localhost:3000",
25 pathname: "/",
26 search: "",
27 assign: vi.fn(),
28 replace: vi.fn(),
29 reload: vi.fn(),
30 },
31 writable: true,
32 configurable: true,
33});
34
35beforeEach(async () => {
36 vi.clearAllMocks();
37 locationHash = "";
38 _testResetState();
39 await waitLocale();
40});
41
42afterEach(() => {
43 vi.restoreAllMocks();
44});