-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsetupJest.ts
25 lines (23 loc) · 929 Bytes
/
setupJest.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
Object.defineProperty(window, 'AudioContext', {
writable: true,
value: class {
gainNode: any = { connect: jest.fn(), gain: {} };
processorNode: any = { connect: jest.fn(), disconnect: jest.fn() };
sourceNode: any = { connect: jest.fn() };
_setMockNodes = ({ gainNode, processorNode, sourceNode }: any) => {
this.gainNode = gainNode;
this.processorNode = processorNode;
this.sourceNode = sourceNode;
};
resume = jest.fn(() => Promise.resolve());
close = jest.fn();
suspend = jest.fn(() => Promise.resolve());
createMediaStreamSource = jest.fn(() => this.sourceNode);
createGain = jest.fn(() => this.gainNode);
createScriptProcessor = jest.fn(() => this.processorNode);
},
});
window.URL = class extends URL {
static createObjectURL = jest.fn();
static revokeObjectURL = jest.fn();
};