|
7 | 7 | */ |
8 | 8 | /* eslint-disable prefer-destructuring */ |
9 | 9 | /* eslint-disable no-global-assign */ |
10 | | -import random from 'math-random'; |
11 | | - |
12 | 10 | let consoleWarns; |
13 | 11 | let createCognitiveServicesSpeechServicesPonyfillFactory; |
14 | 12 | let createPonyfill; |
15 | 13 | let originalConsole; |
16 | 14 |
|
17 | 15 | beforeEach(() => { |
18 | 16 | jest.mock('web-speech-cognitive-services/lib/SpeechServices', () => jest.fn(() => ({}))); |
| 17 | + jest.mock('microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/Exports', () => ({ |
| 18 | + ...jest.requireActual('microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/Exports'), |
| 19 | + PcmRecorder: class MockPcmRecorder { |
| 20 | + // eslint-disable-next-line class-methods-use-this, no-empty-function |
| 21 | + record() {} |
| 22 | + // eslint-disable-next-line class-methods-use-this, no-empty-function |
| 23 | + releaseMediaResources() {} |
| 24 | + // eslint-disable-next-line class-methods-use-this, no-empty-function |
| 25 | + setWorkletUrl() {} |
| 26 | + } |
| 27 | + })); |
19 | 28 |
|
20 | 29 | originalConsole = console; |
21 | 30 | consoleWarns = []; |
@@ -43,15 +52,6 @@ beforeEach(() => { |
43 | 52 | } |
44 | 53 | }; |
45 | 54 |
|
46 | | - window.URL = { |
47 | | - ...window.URL, |
48 | | - // Even when AudioContext does not support audio worklet, PCMRecorder always create it via URL.createObjectURL(). |
49 | | - // As JSDOM does not support URL.createObjectURL(), we need to return a dummy blob URL. |
50 | | - // https://github.com/microsoft/cognitive-services-speech-sdk-js/issues/572 |
51 | | - // eslint-disable-next-line no-magic-numbers |
52 | | - createObjectURL: () => `blob:${random().toString(36).substring(2)}` |
53 | | - }; |
54 | | - |
55 | 55 | window.navigator.mediaDevices = { |
56 | 56 | getUserMedia: jest.fn(() => ({ |
57 | 57 | getAudioTracks: () => ['mock-media-stream-track'] |
|
0 commit comments