Add mocks for Web Audio API (#12457)

This commit is contained in:
woxtu 2023-11-26 09:54:24 +09:00 committed by GitHub
parent 95095ee8d1
commit c8b85a98b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,3 +25,21 @@ vi.mock('@/store.js', () => {
}, },
}; };
}); });
// Add mocks for Web Audio API
const AudioNodeMock = vi.fn(() => ({
connect: vi.fn(() => ({ connect: vi.fn() })),
start: vi.fn(),
}));
const GainNodeMock = vi.fn(() => ({
gain: vi.fn(),
}));
const AudioContextMock = vi.fn(() => ({
createBufferSource: vi.fn(() => new AudioNodeMock()),
createGain: vi.fn(() => new GainNodeMock()),
decodeAudioData: vi.fn(),
}));
vi.stubGlobal('AudioContext', AudioContextMock);