forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ts
More file actions
36 lines (31 loc) · 1017 Bytes
/
Copy pathsetup.ts
File metadata and controls
36 lines (31 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import '@testing-library/jest-dom';
import "../i18n/config";
// Ensure a stable Storage implementation across jsdom/happy-dom.
// Some environments provide a partial localStorage without `clear()`.
const memoryStorage = () => {
let store: Record<string, string> = {};
return {
get length() {
return Object.keys(store).length;
},
key: (index: number) => Object.keys(store)[index] ?? null,
getItem: (key: string) => (key in store ? store[key] : null),
setItem: (key: string, value: string) => {
store[key] = String(value);
},
removeItem: (key: string) => {
delete store[key];
},
clear: () => {
store = {};
},
};
};
if (
typeof globalThis.localStorage === "undefined" ||
typeof (globalThis.localStorage as any).clear !== "function"
) {
(globalThis as unknown as { localStorage: Storage }).localStorage =
memoryStorage() as unknown as Storage;
}
// Api client regression tests mock `apiClient` (api-client.spec.ts) — no real backend.