diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/application/test/node/helpers.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/application/test/node/helpers.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/devtools/client/application/test/node/helpers.js b/devtools/client/application/test/node/helpers.js new file mode 100644 index 0000000000..6699549a15 --- /dev/null +++ b/devtools/client/application/test/node/helpers.js @@ -0,0 +1,31 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { + thunk, +} = require("resource://devtools/client/shared/redux/middleware/thunk.js"); +const configureStore = require("redux-mock-store").default; + +/** + * Prepare the store for use in testing. + */ +function setupStore(preloadedState = {}) { + const middleware = [thunk()]; + const mockStore = configureStore(middleware); + return mockStore(preloadedState); +} + +/** + * This gives an opportunity to Promises to resolve in tests + * (since they are microtasks) + */ +async function flushPromises() { + await new Promise(r => setTimeout(r, 0)); +} + +module.exports = { + flushPromises, + setupStore, +}; |