@@ -69,8 +69,8 @@ describe("browser", () => {
6969 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
7070
7171 WebSocketAPI . fetch ( "something404" , undefined , {
72- use : "ws"
73- } )
72+ use : "ws"
73+ } )
7474 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
7575 . catch ( err => {
7676 try {
@@ -88,8 +88,8 @@ describe("browser", () => {
8888 it ( "should throw error with 'test error'" , function ( done ) {
8989
9090 WebSocketAPI . fetch ( "error" , undefined , {
91- use : "ws"
92- } )
91+ use : "ws"
92+ } )
9393 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
9494 . catch ( err => {
9595 try {
@@ -107,9 +107,9 @@ describe("browser", () => {
107107 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
108108
109109 WebSocketAPI . fetch ( "timeout" , undefined , {
110- use : "ws" ,
111- timeout : 150
112- } )
110+ use : "ws" ,
111+ timeout : 150
112+ } )
113113 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
114114 . catch ( err => {
115115 try {
@@ -148,8 +148,8 @@ describe("browser", () => {
148148 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
149149
150150 WebSocketAPI . fetch ( "something404" , undefined , {
151- use : "http"
152- } )
151+ use : "http"
152+ } )
153153 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
154154 . catch ( err => {
155155 try {
@@ -167,8 +167,8 @@ describe("browser", () => {
167167 it ( "should throw error with 'test error'" , function ( done ) {
168168
169169 WebSocketAPI . fetch ( "error" , undefined , {
170- use : "http"
171- } )
170+ use : "http"
171+ } )
172172 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
173173 . catch ( err => {
174174 try {
@@ -186,9 +186,9 @@ describe("browser", () => {
186186 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
187187
188188 WebSocketAPI . fetch ( "timeout" , undefined , {
189- use : "http" ,
190- timeout : 150
191- } )
189+ use : "http" ,
190+ timeout : 150
191+ } )
192192 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
193193 . catch ( err => {
194194 try {
@@ -203,6 +203,31 @@ describe("browser", () => {
203203 this . timeout ( 200 ) ;
204204 } ) ;
205205
206+ // the get request's body should be readable from server and returned as a echo
207+ it ( "Echo with the request body" , async function ( ) {
208+ this . timeout ( 200 ) ;
209+ const response = await WebSocketAPI . fetch ( "echo" , {
210+ a : 56 ,
211+ b : "c" ,
212+ d : null ,
213+ nested : {
214+ a : 10
215+ }
216+ } , {
217+ use : "http" ,
218+ timeout : 150
219+ } ) ;
220+
221+ // check that the response is equal
222+ assert . deepEqual ( response , {
223+ a : 56 ,
224+ b : "c" ,
225+ d : null ,
226+ nested : {
227+ a : 10
228+ }
229+ } ) ;
230+ } ) ;
206231 } ) ;
207232
208233 } ) ;
@@ -238,9 +263,9 @@ describe("browser", () => {
238263 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
239264
240265 WebSocketAPI . fetch ( "something404" , undefined , {
241- use : "ws" ,
242- method : "POST" ,
243- } )
266+ use : "ws" ,
267+ method : "POST" ,
268+ } )
244269 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
245270 . catch ( err => {
246271 try {
@@ -258,9 +283,9 @@ describe("browser", () => {
258283 it ( "should throw error with 'test error'" , function ( done ) {
259284
260285 WebSocketAPI . fetch ( "error" , postData , {
261- use : "ws" ,
262- method : "POST" ,
263- } )
286+ use : "ws" ,
287+ method : "POST" ,
288+ } )
264289 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
265290 . catch ( err => {
266291 try {
@@ -278,10 +303,10 @@ describe("browser", () => {
278303 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
279304
280305 WebSocketAPI . fetch ( "timeout" , postData , {
281- use : "ws" ,
282- timeout : 150 ,
283- method : "POST" ,
284- } )
306+ use : "ws" ,
307+ timeout : 150 ,
308+ method : "POST" ,
309+ } )
285310 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
286311 . catch ( err => {
287312 try {
@@ -315,9 +340,9 @@ describe("browser", () => {
315340 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
316341
317342 WebSocketAPI . fetch ( "something404" , postData , {
318- use : "http" ,
319- method : "POST" ,
320- } )
343+ use : "http" ,
344+ method : "POST" ,
345+ } )
321346 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
322347 . catch ( err => {
323348 try {
@@ -335,9 +360,9 @@ describe("browser", () => {
335360 it ( "should throw error with 'test error'" , function ( done ) {
336361
337362 WebSocketAPI . fetch ( "error" , postData , {
338- use : "http" ,
339- method : "POST" ,
340- } )
363+ use : "http" ,
364+ method : "POST" ,
365+ } )
341366 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
342367 . catch ( err => {
343368 try {
@@ -355,10 +380,10 @@ describe("browser", () => {
355380 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
356381
357382 WebSocketAPI . fetch ( "timeout" , postData , {
358- use : "http" ,
359- timeout : 150 ,
360- method : "POST" ,
361- } )
383+ use : "http" ,
384+ timeout : 150 ,
385+ method : "POST" ,
386+ } )
362387 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
363388 . catch ( err => {
364389 try {
@@ -408,9 +433,9 @@ describe("browser", () => {
408433 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
409434
410435 WebSocketAPI . fetch ( "something404" , undefined , {
411- use : "ws" ,
412- method : "PUT" ,
413- } )
436+ use : "ws" ,
437+ method : "PUT" ,
438+ } )
414439 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
415440 . catch ( err => {
416441 try {
@@ -428,9 +453,9 @@ describe("browser", () => {
428453 it ( "should throw error with 'test error'" , function ( done ) {
429454
430455 WebSocketAPI . fetch ( "error" , postData , {
431- use : "ws" ,
432- method : "PUT" ,
433- } )
456+ use : "ws" ,
457+ method : "PUT" ,
458+ } )
434459 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
435460 . catch ( err => {
436461 try {
@@ -448,10 +473,10 @@ describe("browser", () => {
448473 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
449474
450475 WebSocketAPI . fetch ( "timeout" , postData , {
451- use : "ws" ,
452- timeout : 150 ,
453- method : "PUT" ,
454- } )
476+ use : "ws" ,
477+ timeout : 150 ,
478+ method : "PUT" ,
479+ } )
455480 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
456481 . catch ( err => {
457482 try {
@@ -485,9 +510,9 @@ describe("browser", () => {
485510 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
486511
487512 WebSocketAPI . fetch ( "something404" , postData , {
488- use : "http" ,
489- method : "PUT" ,
490- } )
513+ use : "http" ,
514+ method : "PUT" ,
515+ } )
491516 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
492517 . catch ( err => {
493518 try {
@@ -505,9 +530,9 @@ describe("browser", () => {
505530 it ( "should throw error with 'test error'" , function ( done ) {
506531
507532 WebSocketAPI . fetch ( "error" , postData , {
508- use : "http" ,
509- method : "PUT" ,
510- } )
533+ use : "http" ,
534+ method : "PUT" ,
535+ } )
511536 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
512537 . catch ( err => {
513538 try {
@@ -525,10 +550,10 @@ describe("browser", () => {
525550 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
526551
527552 WebSocketAPI . fetch ( "timeout" , postData , {
528- use : "http" ,
529- timeout : 150 ,
530- method : "PUT" ,
531- } )
553+ use : "http" ,
554+ timeout : 150 ,
555+ method : "PUT" ,
556+ } )
532557 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
533558 . catch ( err => {
534559 try {
@@ -571,8 +596,8 @@ describe("browser", () => {
571596 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
572597
573598 WebSocketAPI . fetch ( "something404" , undefined , {
574- use : "ws"
575- } )
599+ use : "ws"
600+ } )
576601 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
577602 . catch ( err => {
578603 try {
@@ -590,9 +615,9 @@ describe("browser", () => {
590615 it ( "should throw error with 'test error'" , function ( done ) {
591616
592617 WebSocketAPI . fetch ( "error" , undefined , {
593- use : "ws" ,
594- method : "DELETE"
595- } )
618+ use : "ws" ,
619+ method : "DELETE"
620+ } )
596621 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
597622 . catch ( err => {
598623 try {
@@ -610,10 +635,10 @@ describe("browser", () => {
610635 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
611636
612637 WebSocketAPI . fetch ( "timeout" , undefined , {
613- use : "ws" ,
614- timeout : 150 ,
615- method : "DELETE"
616- } )
638+ use : "ws" ,
639+ timeout : 150 ,
640+ method : "DELETE"
641+ } )
617642 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
618643 . catch ( err => {
619644 try {
@@ -649,9 +674,9 @@ describe("browser", () => {
649674 it ( "should throw error with 'Unknown api request.'" , function ( done ) {
650675
651676 WebSocketAPI . fetch ( "something404" , undefined , {
652- use : "http" ,
653- method : "DELETE"
654- } )
677+ use : "http" ,
678+ method : "DELETE"
679+ } )
655680 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
656681 . catch ( err => {
657682 try {
@@ -669,9 +694,9 @@ describe("browser", () => {
669694 it ( "should throw error with 'test error'" , function ( done ) {
670695
671696 WebSocketAPI . fetch ( "error" , undefined , {
672- use : "http" ,
673- method : "DELETE"
674- } )
697+ use : "http" ,
698+ method : "DELETE"
699+ } )
675700 . then ( _ => done ( new Error ( "Was supposed to throw a error." ) ) )
676701 . catch ( err => {
677702 try {
@@ -689,10 +714,10 @@ describe("browser", () => {
689714 it ( "should throw timeout error with 'Timeout Error'" , function ( done ) {
690715
691716 WebSocketAPI . fetch ( "timeout" , undefined , {
692- use : "http" ,
693- timeout : 150 ,
694- method : "DELETE"
695- } )
717+ use : "http" ,
718+ timeout : 150 ,
719+ method : "DELETE"
720+ } )
696721 . then ( _ => done ( new Error ( "Was supposed to throw a timeout error." ) ) )
697722 . catch ( err => {
698723 try {
0 commit comments