Skip to content

Commit

Permalink
test: when permission are denied
Browse files Browse the repository at this point in the history
  • Loading branch information
evujici committed Sep 20, 2024
1 parent 244749c commit d07eb9b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/device/device-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
createMicrophoneStream,
getDevices,
} from './device-management';
import { WebrtcCoreError, WebrtcCoreErrorType } from '../errors';

jest.mock('../mocks/media-stream-stub');

Expand Down Expand Up @@ -303,5 +304,19 @@ describe('Device Management', () => {
const devices = await getDevices(media.DeviceKind.AudioInput);
expect(devices).toStrictEqual([{ kind: 'audioinput', deviceId: 'audio1' }]);
});

it('should throw WebrtcCoreError when device permissions are denied', async () => {
expect.hasAssertions();
jest.spyOn(media, 'ensureDevicePermissions').mockImplementation(() => {
throw new Error();
});

const expectedError = new WebrtcCoreError(
WebrtcCoreErrorType.DEVICE_PERMISSION_DENIED,
'Failed to ensure device permissions'
);

await expect(getDevices()).rejects.toStrictEqual(expectedError);
});
});
});

0 comments on commit d07eb9b

Please sign in to comment.