forked from input-output-hk/nami
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
22 lines (19 loc) · 804 Bytes
/
jest.setup.js
File metadata and controls
22 lines (19 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Object.assign(global, require('jest-chrome'));
// Treat Jest as the extension environment so `src/platform` uses the adapter with
// mocked chrome.storage (not IndexedDB / web adapter).
global.chrome.runtime.id = 'jest-extension-id';
// mocking the chrome.storage.local API
global.mockStore = {};
global.chrome.storage.local.get = (key, callback) =>
callback(key ? { [key]: global.mockStore[key] } : global.mockStore);
global.chrome.storage.local.set = (item, callback) => {
global.mockStore = { ...global.mockStore, ...item };
callback();
};
global.chrome.storage.local.clear = (callback) => {
global.mockStore = {};
if (typeof callback === 'function') callback();
};
const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;