Add support for connecting microphone on card load.

This commit is contained in:
Dermot Duffy
2023-05-07 15:17:39 -07:00
parent c78d4be0c3
commit ee7d02fc58
11 changed files with 55 additions and 12 deletions
+5 -3
View File
@@ -1,14 +1,16 @@
import { describe, expect, it, vi } from 'vitest';
import { afterAll, describe, expect, it, vi } from 'vitest';
import { log } from '../../src/utils/debug.js';
describe('log', () => {
const spy = vi.spyOn(global.console, 'debug').mockReturnValue(undefined);
afterAll(() => {
vi.resetAllMocks();
});
it('should do nothing without debug logging set', () => {
const spy = vi.spyOn(global.console, 'debug');
log({}, 'foo');
expect(spy).not.toBeCalled();
});
it('should log debug when appropriately configured', () => {
const spy = vi.spyOn(global.console, 'debug');
log({ debug: { logging: true } }, 'foo');
expect(spy).toBeCalledWith('foo');
});
+3
View File
@@ -15,6 +15,7 @@ describe('MicrophoneController', () => {
});
afterEach(() => {
vi.resetAllMocks();
vi.unstubAllGlobals;
});
@@ -48,6 +49,8 @@ describe('MicrophoneController', () => {
});
it('should be forbidden when permission denied', async () => {
// Don't actually log messages to the console during the test.
vi.spyOn(global.console, 'warn').mockReturnValue(undefined);
const controller = new MicrophoneController();
navigatorMock.mediaDevices.getUserMedia.mockRejectedValue(new Error());
await controller.connect();