# All files / src jestGlobalMocks.ts

100% Statements 12/12
100% Branches 4/4
100% Functions 7/7
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20202x
    404x
    404x
    1223x
    246x
    26x
    13x

    202x
    202x
    202x
    360x

    150x

     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: () => ({
        getPropertyValue: () => {
          return '';
        }
      })
    });