1
1
import { expect } from 'chai' ;
2
2
import * as sinon from 'sinon' ;
3
- import { websocket } from 'rxjs/websocket ' ;
3
+ import { webSocket } from 'rxjs/webSocket ' ;
4
4
import { map , retry , take , repeat , takeWhile } from 'rxjs/operators' ;
5
5
6
6
declare const __root__ : any ;
7
7
8
8
/** @test {webSocket} */
9
- describe ( 'websocket ' , ( ) => {
9
+ describe ( 'webSocket ' , ( ) => {
10
10
let __ws : any ;
11
11
12
12
function setupMockWebSocket ( ) {
@@ -30,7 +30,7 @@ describe('websocket', () => {
30
30
31
31
it ( 'should send and receive messages' , ( ) => {
32
32
let messageReceived = false ;
33
- const subject = websocket < string > ( 'ws://mysocket' ) ;
33
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
34
34
35
35
subject . next ( 'ping' ) ;
36
36
@@ -52,7 +52,7 @@ describe('websocket', () => {
52
52
} ) ;
53
53
54
54
it ( 'should allow use of operators and subscribe' , ( ) => {
55
- const subject = websocket < string > ( 'ws://mysocket' ) ;
55
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
56
56
const results : any [ ] = [ ] ;
57
57
58
58
subject . pipe (
@@ -68,7 +68,7 @@ describe('websocket', () => {
68
68
it ( 'receive multiple messages' , ( ) => {
69
69
const expected = [ 'what' , 'do' , 'you' , 'do' , 'with' , 'a' , 'drunken' , 'sailor?' ] ;
70
70
const results : string [ ] = [ ] ;
71
- const subject = websocket < string > ( 'ws://mysocket' ) ;
71
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
72
72
73
73
subject . subscribe ( x => {
74
74
results . push ( x ) ;
@@ -89,7 +89,7 @@ describe('websocket', () => {
89
89
90
90
it ( 'should queue messages prior to subscription' , ( ) => {
91
91
const expected = [ 'make' , 'him' , 'walk' , 'the' , 'plank' ] ;
92
- const subject = websocket < string > ( 'ws://mysocket' ) ;
92
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
93
93
94
94
expected . forEach ( x => {
95
95
subject . next ( x ) ;
@@ -110,7 +110,7 @@ describe('websocket', () => {
110
110
} ) ;
111
111
112
112
it ( 'should send messages immediately if already open' , ( ) => {
113
- const subject = websocket < string > ( 'ws://mysocket' ) ;
113
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
114
114
subject . subscribe ( ) ;
115
115
const socket = MockWebSocket . lastSocket ;
116
116
socket . open ( ) ;
@@ -124,7 +124,7 @@ describe('websocket', () => {
124
124
} ) ;
125
125
126
126
it ( 'should close the socket when completed' , ( ) => {
127
- const subject = websocket < string > ( 'ws://mysocket' ) ;
127
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
128
128
subject . subscribe ( ) ;
129
129
const socket = MockWebSocket . lastSocket ;
130
130
socket . open ( ) ;
@@ -144,7 +144,7 @@ describe('websocket', () => {
144
144
} ) ;
145
145
146
146
it ( 'should close the socket with a code and a reason when errored' , ( ) => {
147
- const subject = websocket < string > ( 'ws://mysocket' ) ;
147
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
148
148
subject . subscribe ( ) ;
149
149
const socket = MockWebSocket . lastSocket ;
150
150
socket . open ( ) ;
@@ -160,7 +160,7 @@ describe('websocket', () => {
160
160
} ) ;
161
161
162
162
it ( 'should allow resubscription after closure via complete' , ( ) => {
163
- const subject = websocket < string > ( 'ws://mysocket' ) ;
163
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
164
164
subject . subscribe ( ) ;
165
165
const socket1 = MockWebSocket . lastSocket ;
166
166
socket1 . open ( ) ;
@@ -178,7 +178,7 @@ describe('websocket', () => {
178
178
} ) ;
179
179
180
180
it ( 'should allow resubscription after closure via error' , ( ) => {
181
- const subject = websocket < string > ( 'ws://mysocket' ) ;
181
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
182
182
subject . subscribe ( ) ;
183
183
const socket1 = MockWebSocket . lastSocket ;
184
184
socket1 . open ( ) ;
@@ -198,7 +198,7 @@ describe('websocket', () => {
198
198
it ( 'should have a default resultSelector that parses message data as JSON' , ( ) => {
199
199
let result ;
200
200
const expected = { mork : 'shazbot!' } ;
201
- const subject = websocket < string > ( 'ws://mysocket' ) ;
201
+ const subject = webSocket < string > ( 'ws://mysocket' ) ;
202
202
203
203
subject . subscribe ( ( x : any ) => {
204
204
result = x ;
@@ -226,7 +226,7 @@ describe('websocket', () => {
226
226
227
227
it ( 'should send and receive messages' , ( ) => {
228
228
let messageReceived = false ;
229
- const subject = websocket < string > ( { url : 'ws://mysocket' } ) ;
229
+ const subject = webSocket < string > ( { url : 'ws://mysocket' } ) ;
230
230
231
231
subject . next ( 'ping' ) ;
232
232
@@ -248,7 +248,7 @@ describe('websocket', () => {
248
248
} ) ;
249
249
250
250
it ( 'should take a protocol and set it properly on the web socket' , ( ) => {
251
- const subject = websocket < string > ( {
251
+ const subject = webSocket < string > ( {
252
252
url : 'ws://mysocket' ,
253
253
protocol : 'someprotocol'
254
254
} ) ;
@@ -262,7 +262,7 @@ describe('websocket', () => {
262
262
} ) ;
263
263
264
264
it ( 'should take a binaryType and set it properly on the web socket' , ( ) => {
265
- const subject = websocket < string > ( {
265
+ const subject = webSocket < string > ( {
266
266
url : 'ws://mysocket' ,
267
267
binaryType : 'blob'
268
268
} ) ;
@@ -278,7 +278,7 @@ describe('websocket', () => {
278
278
it ( 'should take a deserializer' , ( ) => {
279
279
const results = [ ] as string [ ] ;
280
280
281
- const subject = websocket < string > ( {
281
+ const subject = webSocket < string > ( {
282
282
url : 'ws://mysocket' ,
283
283
deserializer : ( e : any ) => {
284
284
return e . data + '!' ;
@@ -301,7 +301,7 @@ describe('websocket', () => {
301
301
} ) ;
302
302
303
303
it ( 'if the deserializer fails it should go down the error path' , ( ) => {
304
- const subject = websocket < string > ( {
304
+ const subject = webSocket < string > ( {
305
305
url : 'ws://mysocket' ,
306
306
deserializer : ( e : any ) => {
307
307
throw new Error ( 'I am a bad error' ) ;
@@ -323,7 +323,7 @@ describe('websocket', () => {
323
323
324
324
it ( 'should accept a closingObserver' , ( ) => {
325
325
let calls = 0 ;
326
- const subject = websocket < string > ( < any > {
326
+ const subject = webSocket < string > ( < any > {
327
327
url : 'ws://mysocket' ,
328
328
closingObserver : {
329
329
next ( x : any ) {
@@ -355,7 +355,7 @@ describe('websocket', () => {
355
355
it ( 'should accept a closeObserver' , ( ) => {
356
356
const expected = [ { wasClean : true } , { wasClean : false } ] ;
357
357
const closes = [ ] as any [ ] ;
358
- const subject = websocket < string > ( < any > {
358
+ const subject = webSocket < string > ( < any > {
359
359
url : 'ws://mysocket' ,
360
360
closeObserver : {
361
361
next ( e : any ) {
@@ -390,7 +390,7 @@ describe('websocket', () => {
390
390
} ) ;
391
391
392
392
it ( 'should handle constructor errors' , ( ) => {
393
- const subject = websocket < string > ( < any > {
393
+ const subject = webSocket < string > ( < any > {
394
394
url : 'bad_url' ,
395
395
WebSocketCtor : ( url : string , protocol ?: string | string [ ] ) : WebSocket => {
396
396
throw new Error ( `connection refused` ) ;
@@ -419,7 +419,7 @@ describe('websocket', () => {
419
419
420
420
it ( 'should be retryable' , ( ) => {
421
421
const results = [ ] as string [ ] ;
422
- const subject = websocket < { name : string , value : string } > ( 'ws://websocket' ) ;
422
+ const subject = webSocket < { name : string , value : string } > ( 'ws://websocket' ) ;
423
423
const source = subject . multiplex (
424
424
( ) => ( { sub : 'foo' } ) ,
425
425
( ) => ( { unsub : 'foo' } ) ,
@@ -454,7 +454,7 @@ describe('websocket', () => {
454
454
455
455
it ( 'should be repeatable' , ( ) => {
456
456
const results = [ ] as string [ ] ;
457
- const subject = websocket < { name : string , value : string } > ( 'ws://websocket' ) ;
457
+ const subject = webSocket < { name : string , value : string } > ( 'ws://websocket' ) ;
458
458
const source = subject . multiplex (
459
459
( ) => ( { sub : 'foo' } ) ,
460
460
( ) => ( { unsub : 'foo' } ) ,
@@ -490,9 +490,9 @@ describe('websocket', () => {
490
490
expect ( results ) . to . deep . equal ( [ 'test' , 'this' , 'test' ,
10000
9;this' ] , 'results were not equal' ) ;
491
491
} ) ;
492
492
493
- it ( 'should multiplex over the websocket ' , ( ) => {
493
+ it ( 'should multiplex over the webSocket ' , ( ) => {
494
494
const results = [ ] as Array < { value : number , name : string } > ;
495
- const subject = websocket < { value : number , name : string } > ( 'ws://websocket' ) ;
495
+ const subject = webSocket < { value : number , name : string } > ( 'ws://websocket' ) ;
496
496
const source = subject . multiplex (
497
497
( ) => ( { sub : 'foo' } ) ,
498
498
( ) => ( { unsub : 'foo' } ) ,
@@ -527,7 +527,7 @@ describe('websocket', () => {
527
527
} ) ;
528
528
529
529
it ( 'should keep the same socket for multiple multiplex subscriptions' , ( ) => {
530
- const socketSubject = websocket < string > ( { url : 'ws://mysocket' } ) ;
530
+ const socketSubject = webSocket < string > ( { url : 'ws://mysocket' } ) ;
531
531
const results = [ ] as string [ ] ;
532
532
const socketMessages = [
533
533
{ id : 'A' } ,
@@ -584,7 +584,7 @@ describe('websocket', () => {
584
584
} ) ;
585
585
586
586
it ( 'should not close the socket until all subscriptions complete' , ( ) => {
587
- const socketSubject = websocket < { id : string , complete : boolean } > ( { url : 'ws://mysocket' } ) ;
587
+ const socketSubject = webSocket < { id : string , complete : boolean } > ( { url : 'ws://mysocket' } ) ;
588
588
const results = [ ] as string [ ] ;
589
589
const socketMessages = [
590
590
{ id : 'A' } ,
0 commit comments