aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/jestGlobalMocks.ts
blob: 5486d7c9a0a3f16bd79ed38b285d50e59d2493a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const mock = () => {
  let storage = {};
  return {
    getItem: key => key in storage ? storage[key] : null,
    setItem: (key, value) => storage[key] = value || '',
    removeItem: key => delete storage[key],
    clear: () => storage = {},
  };
};

Object.defineProperty(window, 'localStorage', {value: mock()});
Object.defineProperty(window, 'sessionStorage', {value: mock()});
Object.defineProperty(window, 'getComputedStyle', {
  value: () => ['-webkit-appearance']
});