]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/jestGlobalMocks.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / jestGlobalMocks.ts
CommitLineData
11fdf7f2
TL
1const mock = () => {
2 let storage = {};
3 return {
9f95a23c
TL
4 getItem: (key: string) => (key in storage ? storage[key] : null),
5 setItem: (key: string, value: any) => (storage[key] = value || ''),
6 removeItem: (key: string) => delete storage[key],
11fdf7f2
TL
7 clear: () => (storage = {})
8 };
9};
10
11Object.defineProperty(window, 'localStorage', { value: mock() });
12Object.defineProperty(window, 'sessionStorage', { value: mock() });
13Object.defineProperty(window, 'getComputedStyle', {
14 value: () => ({
15 getPropertyValue: () => {
16 return '';
17 }
18 })
19});