@@ -2,6 +2,9 @@ import { expect } from '@jest/globals';
2
2
import { RTCPeerConnection , RTCDataChannel } from '../../src/polyfill/index' ;
3
3
4
4
describe ( 'polyfill' , ( ) => {
5
+ // Default is 5000 ms but we need more
6
+ jest . setTimeout ( 30000 ) ;
7
+
5
8
test ( 'generateCertificate should throw' , async ( ) => {
6
9
await expect ( async ( ) => {
7
10
await RTCPeerConnection . generateCertificate ( ) ;
@@ -29,7 +32,7 @@ describe('polyfill', () => {
29
32
peerIdentity : 'peer1' ,
30
33
iceServers : [ { urls : [ 'stun:stun.l.google.com:19302' ] } ] ,
31
34
} ) ;
32
-
35
+
33
36
const peer2 = new RTCPeerConnection ( {
34
37
peerIdentity : 'peer2' ,
35
38
iceServers : [ { urls : [ 'stun:stun.l.google.com:19302' ] } ] ,
@@ -54,7 +57,7 @@ describe('polyfill', () => {
54
57
const dv = new DataView ( binaryData ) ;
55
58
return ( dv . getInt8 ( 0 ) == 123 && dv . getFloat32 ( 1 ) == Math . fround ( 123.456 ) && dv . getUint32 ( 5 ) == 987654321 && dv . getFloat64 ( 9 ) == 789.012 ) ;
56
59
}
57
-
60
+
58
61
// We will set the "binaryType" and then send/receive the "data" from the datachannel in each test, and then compare them.
59
62
// For example, the first line will send a "Hello" string after setting binaryType to "arraybuffer".
60
63
const testMessages = [
@@ -136,7 +139,7 @@ describe('polyfill', () => {
136
139
// Send the test message
137
140
dc1 . send ( current . data ) ;
138
141
}
139
-
142
+
140
143
// Set Callbacks
141
144
peer1 . onconnectionstatechange = ( ) : void => {
142
145
p1ConnectionStateMock ( ) ;
@@ -151,7 +154,7 @@ describe('polyfill', () => {
151
154
p1IceCandidateMock ( ) ;
152
155
peer2 . addIceCandidate ( e . candidate ) ;
153
156
} ;
154
-
157
+
155
158
// Set Callbacks
156
159
peer2 . onconnectionstatechange = ( ) : void => {
157
160
p2ConnectionStateMock ( ) ;
@@ -185,15 +188,15 @@ describe('polyfill', () => {
185
188
peer2 . setRemoteDescription ( desc ) ;
186
189
} )
187
190
//.catch((err) => console.error(err));
188
-
191
+
189
192
peer2
190
193
. createAnswer ( )
191
194
. then ( ( answerDesc ) => {
192
195
p2SDPMock ( ) ;
193
196
peer1 . setRemoteDescription ( answerDesc ) ;
194
197
} )
195
198
//.catch((err) => console.error('Couldn't create answer', err));
196
-
199
+
197
200
dc1 = peer1 . createDataChannel ( 'test-p2p' ) ;
198
201
dc1 . onopen = ( ) : void => {
199
202
p1DCMock ( ) ;
0 commit comments