tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

helpers.js (722B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const {
      7  thunk,
      8 } = require("resource://devtools/client/shared/redux/middleware/thunk.js");
      9 const configureStore = require("redux-mock-store").default;
     10 
     11 /**
     12 * Prepare the store for use in testing.
     13 */
     14 function setupStore(preloadedState = {}) {
     15  const middleware = [thunk()];
     16  const mockStore = configureStore(middleware);
     17  return mockStore(preloadedState);
     18 }
     19 
     20 /**
     21 * This gives an opportunity to Promises to resolve in tests
     22 * (since they are microtasks)
     23 */
     24 async function flushPromises() {
     25  await new Promise(r => setTimeout(r, 0));
     26 }
     27 
     28 module.exports = {
     29  flushPromises,
     30  setupStore,
     31 };