-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-jest.ts
52 lines (46 loc) · 1.65 KB
/
setup-jest.ts
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
import { PatchConnection } from 'src/app/services/patch-connection.model';
const mock = () => {
let storage: { [key: string]: string } = {};
return {
getItem: (key: string) => (key in storage ? storage[key] : null),
setItem: (key: string, value: string) => (storage[key] = value || ''),
removeItem: (key: string) => delete storage[key],
clear: () => (storage = {}),
};
};
Object.defineProperty(window, 'localStorage', { value: mock() });
Object.defineProperty(window, 'sessionStorage', { value: mock() });
Object.defineProperty(window, 'getComputedStyle', {
value: () => ['-webkit-appearance'],
});
const mockPatchConnection: PatchConnection = {
requestStatusUpdate: jest.fn(),
addStatusListener: jest.fn(),
removeStatusListener: jest.fn(),
resetToInitialState: jest.fn(),
sendEventOrValue: jest.fn(),
sendMIDIInputEvent: jest.fn(),
sendParameterGestureStart: jest.fn(),
sendParameterGestureEnd: jest.fn(),
requestStoredStateValue: jest.fn(),
sendStoredStateValue: jest.fn(),
addStoredStateValueListener: jest.fn(),
removeStoredStateValueListener: jest.fn(),
sendFullStoredState: jest.fn(),
requestFullStoredState: jest.fn(),
addEndpointEventListener: jest.fn(),
removeEndpointEventListener: jest.fn(),
requestParameterValue: jest.fn(),
addParameterListener: jest.fn(),
removeParameterListener: jest.fn(),
addAllParameterListener: jest.fn(),
removeAllParameterListener: jest.fn(),
getResourceAddress: jest.fn(),
};
Object.defineProperty(window, 'parent', {
value: {
patchConnection: mockPatchConnection,
},
});
/* output shorter and more meaningful Zone error stack traces */
// Error.stackTraceLimit = 2;