hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | // Node exposes an experimental global localStorage that is undefined unless a |
| 2 | // --localstorage-file is provided, and this jsdom version does not expose one |
| 3 | // for the configured test origin. Keep the test storage local to each worker. |
| 4 | if (typeof window !== "undefined") { |
| 5 | // jsdom intentionally does not implement scrolling and logs a warning when |
| 6 | // UI code calls it. Scrolling is outside the scope of these component tests. |
| 7 | window.scrollTo = () => undefined; |
| 8 | Element.prototype.scrollIntoView = () => undefined; |
| 9 | const values = new Map<string, string>(); |
| 10 | const storage = { |
| 11 | get length() { return values.size; }, |
| 12 | clear() { values.clear(); }, |
| 13 | getItem(key: string) { return values.get(String(key)) ?? null; }, |
| 14 | key(index: number) { return Array.from(values.keys())[index] ?? null; }, |
| 15 | removeItem(key: string) { values.delete(String(key)); }, |
| 16 | setItem(key: string, value: string) { values.set(String(key), String(value)); }, |
| 17 | }; |
| 18 | Object.defineProperty(window, "localStorage", { configurable: true, value: storage }); |
| 19 | Object.defineProperty(window, "sessionStorage", { configurable: true, value: storage }); |
| 20 | Object.defineProperty(globalThis, "localStorage", { |
| 21 | configurable: true, |
| 22 | value: storage, |
| 23 | }); |
| 24 | Object.defineProperty(globalThis, "sessionStorage", { |
| 25 | configurable: true, |
| 26 | value: window.sessionStorage, |
| 27 | }); |
| 28 | } |