@@ -5,34 +5,34 @@ describe("RtcStream", () => {
5
5
it ( "should throw error if id is null" , ( ) => {
6
6
expect ( ( ) => {
7
7
new RtcStream ( null , STREAM_TYPES . SCREEN_SHARE ) ; //eslint-disable-line no-new
8
- } ) . to . throw ( "id is required" ) ;
8
+ } ) . toThrow ( "id is required" ) ;
9
9
} ) ;
10
10
11
11
it ( "should throw error if id is undefined" , ( ) => {
12
12
expect ( ( ) => {
13
13
new RtcStream ( undefined , STREAM_TYPES . SCREEN_SHARE ) ; //eslint-disable-line no-new
14
- } ) . to . throw ( "id is required" ) ;
14
+ } ) . toThrow ( "id is required" ) ;
15
15
} ) ;
16
16
17
17
it ( "should throw error if type is missing" , ( ) => {
18
18
expect ( ( ) => {
19
19
new RtcStream ( "1" ) ; //eslint-disable-line no-new
20
- } ) . to . throw ( "type is required" ) ;
20
+ } ) . toThrow ( "type is required" ) ;
21
21
} ) ;
22
22
23
23
it ( "should create a stream with a string id if the specified id is a number" , ( ) => {
24
24
const stream = new RtcStream ( 1 , STREAM_TYPES . SCREEN_SHARE ) ;
25
25
26
- expect ( stream . id ) . to . deep . equals ( "1" ) ;
26
+ expect ( stream . id ) . toEqual ( "1" ) ;
27
27
} ) ;
28
28
29
29
it ( "should create a stream with the specified id and type" , ( ) => {
30
30
const streamId = "1" ;
31
31
const streamType = STREAM_TYPES . SCREEN_SHARE ;
32
32
const stream = new RtcStream ( streamId , streamType ) ;
33
33
34
- expect ( stream . id ) . to . deep . equals ( streamId ) ;
35
- expect ( stream . type ) . to . deep . equals ( streamType ) ;
34
+ expect ( stream . id ) . toEqual ( streamId ) ;
35
+ expect ( stream . type ) . toEqual ( streamType ) ;
36
36
} ) ;
37
37
} ) ;
38
38
@@ -42,29 +42,29 @@ describe("RtcStream", () => {
42
42
43
43
beforeEach ( ( ) => {
44
44
fakeStream = {
45
- getVideoTracks : sinon . stub ( ) . returns ( [ { enabled : true } ] ) ,
46
- getAudioTracks : sinon . stub ( ) . returns ( [ { enabled : true } ] ) ,
45
+ getVideoTracks : jest . fn ( ) . mockReturnValue ( [ { enabled : true } ] ) ,
46
+ getAudioTracks : jest . fn ( ) . mockReturnValue ( [ { enabled : true } ] ) ,
47
47
} ;
48
48
} ) ;
49
49
50
50
it ( "applies isVideoEnabled state override from earlier" , ( ) => {
51
51
const stream = new RtcStream ( "id" , "type" ) ;
52
52
stream . isVideoEnabled = false ;
53
- sinon . spy ( stream , "setVideoEnabled" ) ;
53
+ jest . spyOn ( stream , "setVideoEnabled" ) ;
54
54
55
55
stream . setup ( fakeStream ) ;
56
56
57
- expect ( stream . setVideoEnabled ) . to . have . been . calledWithExactly ( false ) ;
57
+ expect ( stream . setVideoEnabled ) . toHaveBeenCalledWith ( false ) ;
58
58
} ) ;
59
59
60
60
it ( "applies isAudioEnabled state override from earlier" , ( ) => {
61
61
const stream = new RtcStream ( "id" , "type" ) ;
62
62
stream . isAudioEnabled = false ;
63
- sinon . spy ( stream , "setAudioEnabled" ) ;
63
+ jest . spyOn ( stream , "setAudioEnabled" ) ;
64
64
65
65
stream . setup ( fakeStream ) ;
66
66
67
- expect ( stream . setAudioEnabled ) . to . have . been . calledWithExactly ( false ) ;
67
+ expect ( stream . setAudioEnabled ) . toHaveBeenCalledWith ( false ) ;
68
68
} ) ;
69
69
} ) ;
70
70
} ) ;
@@ -74,31 +74,31 @@ describe("RtcStream", () => {
74
74
beforeEach ( ( ) => {
75
75
stream = new RtcStream ( "id" , STREAM_TYPES . CAMERA ) ;
76
76
stream . stream = {
77
- getAudioTracks : sinon . stub ( ) . returns ( [ ] ) ,
78
- getVideoTracks : sinon . stub ( ) . returns ( [ ] ) ,
77
+ getAudioTracks : jest . fn ( ) . mockReturnValue ( [ ] ) ,
78
+ getVideoTracks : jest . fn ( ) . mockReturnValue ( [ ] ) ,
79
79
} ;
80
80
} ) ;
81
81
82
82
it ( "defaults to being true" , ( ) => {
83
- expect ( stream . isAudioEnabled ) . to . equal ( true ) ;
83
+ expect ( stream . isAudioEnabled ) . toEqual ( true ) ;
84
84
} ) ;
85
85
86
86
it ( "sets isAudioEnabled to the given value" , ( ) => {
87
87
const expectedValue = false ;
88
88
89
89
stream . setAudioEnabled ( expectedValue ) ;
90
90
91
- expect ( stream . isAudioEnabled ) . to . equal ( expectedValue ) ;
91
+ expect ( stream . isAudioEnabled ) . toEqual ( expectedValue ) ;
92
92
} ) ;
93
93
94
94
it ( "sets each stream's track' enabled property" , ( ) => {
95
95
const track = { } ;
96
- stream . stream . getAudioTracks = sinon . stub ( ) . returns ( [ track ] ) ;
96
+ stream . stream . getAudioTracks = jest . fn ( ) . mockReturnValue ( [ track ] ) ;
97
97
98
98
const expectedValue = true ;
99
99
stream . setAudioEnabled ( expectedValue ) ;
100
100
101
- expect ( track . enabled ) . to . equal ( expectedValue ) ;
101
+ expect ( track . enabled ) . toEqual ( expectedValue ) ;
102
102
} ) ;
103
103
} ) ;
104
104
@@ -107,31 +107,31 @@ describe("RtcStream", () => {
107
107
beforeEach ( ( ) => {
108
108
stream = new RtcStream ( "id" , STREAM_TYPES . CAMERA ) ;
109
109
stream . stream = {
110
- getAudioTracks : sinon . stub ( ) . returns ( [ ] ) ,
111
- getVideoTracks : sinon . stub ( ) . returns ( [ ] ) ,
110
+ getAudioTracks : jest . fn ( ) . mockReturnValue ( [ ] ) ,
111
+ getVideoTracks : jest . fn ( ) . mockReturnValue ( [ ] ) ,
112
112
} ;
113
113
} ) ;
114
114
115
115
it ( "defaults to being true" , ( ) => {
116
- expect ( stream . isVideoEnabled ) . to . equal ( true ) ;
116
+ expect ( stream . isVideoEnabled ) . toEqual ( true ) ;
117
117
} ) ;
118
118
119
119
it ( "sets isVideoEnabled to the given value" , ( ) => {
120
120
const expectedValue = false ;
121
121
122
122
stream . setVideoEnabled ( expectedValue ) ;
123
123
124
- expect ( stream . isVideoEnabled ) . to . equal ( expectedValue ) ;
124
+ expect ( stream . isVideoEnabled ) . toEqual ( expectedValue ) ;
125
125
} ) ;
126
126
127
127
it ( "sets each stream's track' enabled property" , ( ) => {
128
128
const track = { } ;
129
- stream . stream . getVideoTracks = sinon . stub ( ) . returns ( [ track ] ) ;
129
+ stream . stream . getVideoTracks = jest . fn ( ) . mockReturnValue ( [ track ] ) ;
130
130
131
131
const expectedValue = true ;
132
132
stream . setVideoEnabled ( expectedValue ) ;
133
133
134
- expect ( track . enabled ) . to . equal ( expectedValue ) ;
134
+ expect ( track . enabled ) . toEqual ( expectedValue ) ;
135
135
} ) ;
136
136
} ) ;
137
137
} ) ;
0 commit comments