-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-tests.js
62 lines (50 loc) · 1.92 KB
/
setup-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import '@testing-library/jest-dom';
import {JSDOM} from 'jsdom';
jest.mock('esm', () => {
return module => module.require;
});
import {NetworkManager} from './packages/wasm/src/modules/network-manager';
import {getStorage} from './packages/wasm/src/core/storage';
import {mockDockService} from '@docknetwork/wallet-sdk-wasm/src/services/test-utils';
import {setV1LocalStorage} from '@docknetwork/wallet-sdk-data-store-typeorm/src/migration/migration1/v1-data-store';
import {setLocalStorage} from '@docknetwork/wallet-sdk-data-store/src';
NetworkManager.getInstance().setNetworkId('testnet');
mockDockService();
process.env.ENCRYPTION_KEY =
'776fe87eec8c9ba8417beda00b23cf22f5e134d9644d0a195cd9e0b7373760c1';
const cfg = {url: 'http://localhost'};
const dom = new JSDOM('', cfg);
global.window = dom.window;
global.document = dom.window.document;
//
// Object.keys(global.window).forEach(property => {
// if (typeof global[property] === 'undefined') {
// global[property] = global.window[property];
// }
// });
global.navigator = {
userAgent: 'node.js',
appVersion: [],
};
require('@docknetwork/wallet-sdk-wasm/src/setup-tests');
jest.mock('@react-native-async-storage/async-storage', () => 'AsyncStorage');
jest.mock('@docknetwork/sdk/presentation', () => {
const mockAddCredentialToPresent = jest.fn(() => 0);
const mockAddAttributeToReveal = jest.fn();
const mockCreatePresentation = jest.fn();
const mockDeriveCredentials = jest.fn(() => []);
return jest.fn().mockImplementation(() => {
return {
addCredentialToPresent: mockAddCredentialToPresent,
addAttributeToReveal: mockAddAttributeToReveal,
createPresentation: mockCreatePresentation,
deriveCredentials: mockDeriveCredentials,
presBuilder: {
enforceBounds: jest.fn(),
},
};
});
});
setV1LocalStorage(global.localStorage);
setLocalStorage(global.localStorage);
global.localStorage.setItem('networkId', 'testnet');