<commit_before>// https://stackoverflow.com
//        /questions/32911630/how-do-i-deal-with-localstorage-in-jest-tests

// https://github.com/facebook/jest/issues/2098
function whatever() {
  var store = {};

  return {
    store,
    clear() {
      store = {};
    },
    getItem(key) {
      return store[key];
    },
    setItem(key, value) {
      store[key] = value.toString();
    },
    removeItem(key) {
      delete store[key];
    }
  }
}

global.localStorage = whatever();
global.sessionStorage = whatever();<commit_msg>Fix issue with localstorage.js setItem / getItem<commit_after>// https://stackoverflow.com
//        /questions/32911630/how-do-i-deal-with-localstorage-in-jest-tests

// https://github.com/facebook/jest/issues/2098
function Whatever() {
  var store = {};

  store.isFakeStore = true;

  store.getItem = (key) => {
    return store[key];
  };

  store.setItem = (key, value) => {
    store[key] = value;
  };

  store.removeItem = (key) => {
    store[key] = undefined;
  };

  return store;
}

global.localStorage = Whatever();
global.sessionStorage = Whatever();
{'fraction_non_alphanumeric': 0.16864175022789427, 'fraction_numerical': 0.02187784867821331, 'mean_word_length': 2.7993079584775087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5988636', 'n_tokens_mistral': 390, 'n_tokens_neox': 362, 'n_words': 59}