-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jest): 75% coverage for components/mixins/UserPermissions
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
components/mixins/UserPermissions/__snapshots__/index.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`index.UserPermissions.created 0 1`] = `undefined`; | ||
|
||
exports[`index.exportForTesting.formatDevices 0 1`] = ` | ||
Array [ | ||
Object { | ||
"text": "videoinput: FaceTime HD Camera (Built-in) ", | ||
"value": "id=csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8=", | ||
}, | ||
Object { | ||
"text": "audioinput: default (Built-in Microphone) ", | ||
"value": "id=RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM=", | ||
}, | ||
Object { | ||
"text": "audioinput: Built-in Microphone ", | ||
"value": "id=r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=", | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,55 @@ | ||
import { result } from 'lodash' | ||
import * as index from '~/components/mixins/UserPermissions/index' | ||
|
||
describe('index.UserPermissions.created', () => { | ||
test('0', () => { | ||
const result: any = index.UserPermissions.created() | ||
expect(result).toMatchSnapshot() | ||
}) | ||
}) | ||
describe('index.UserPermissions.methods.getUserPermissions', () => { | ||
test('0', async () => { | ||
await index.UserPermissions.methods.getUserPermissions() | ||
}) | ||
}) | ||
describe('index.UserPermissions.methods.requestUserPermissions', () => { | ||
test('0', async () => { | ||
const mockObj = { a: 'b' } | ||
window.navigator = jest.fn() | ||
window.navigator.mediaDevices = jest.fn() | ||
window.navigator.mediaDevices.getUserMedia = jest | ||
.fn() | ||
.mockReturnValueOnce(mockObj) | ||
|
||
const result = await index.UserPermissions.methods.requestUserPermissions({ | ||
audio: true, | ||
peerIdentity: 'identity', | ||
preferCurrentTab: true, | ||
video: false, | ||
}) | ||
|
||
expect(result).toMatchObject(mockObj) | ||
}) | ||
}) | ||
describe('index.exportForTesting.formatDevices', () => { | ||
test('0', async () => { | ||
const devices = [ | ||
{ | ||
label: 'videoinput: FaceTime HD Camera (Built-in) ', | ||
deviceId: 'id=csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8=', | ||
}, | ||
{ | ||
label: 'audioinput: default (Built-in Microphone) ', | ||
deviceId: 'id=RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM=', | ||
}, | ||
{ | ||
label: 'audioinput: Built-in Microphone ', | ||
deviceId: 'id=r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=', | ||
}, | ||
] | ||
|
||
const result = await index.exportForTesting.formatDevices(devices) | ||
|
||
expect(result).toMatchSnapshot() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters