File tree 2 files changed +15
-3
lines changed 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,10 @@ function getAuthStatus(type) {
18
18
}
19
19
20
20
function askForMediaAccess ( type , callback ) {
21
- if ( [ 'microphone' , 'camera' ] . includes ( type ) ) {
21
+ if ( ! [ 'microphone' , 'camera' ] . includes ( type ) ) {
22
22
throw new TypeError ( `${ type } must be either 'camera' or 'microphone'` )
23
23
}
24
+
24
25
if ( typeof callback !== 'function' ) {
25
26
throw new TypeError ( `callback must be a function` )
26
27
}
Original file line number Diff line number Diff line change 1
1
const { expect } = require ( 'chai' )
2
2
const {
3
- getAuthStatus
3
+ getAuthStatus,
4
+ askForMediaAccess
4
5
} = require ( '../index' )
5
6
6
7
describe ( 'node-mac-permissions' , ( ) => {
@@ -28,4 +29,14 @@ describe('node-mac-permissions', () => {
28
29
}
29
30
} )
30
31
} )
31
- } )
32
+
33
+ describe ( 'askForMediaAccess(type, callback)' , ( ) => {
34
+ it ( 'throws on invalid media types' , ( ) => {
35
+ expect ( ( ) => {
36
+ askForMediaAccess ( 'bad-type' , ( status ) => {
37
+ console . log ( status )
38
+ } )
39
+ } ) . to . throw ( / b a d - t y p e m u s t b e e i t h e r ' c a m e r a ' o r ' m i c r o p h o n e ' / )
40
+ } )
41
+ } )
42
+ } )
You can’t perform that action at this time.
0 commit comments