@@ -95,10 +95,10 @@ describe("SimpleHttpRendezvousTransport", function () {
95
95
httpBackend . verifyNoOutstandingExpectation ( ) ;
96
96
}
97
97
}
98
- it ( "should throw an error when no server available" , function ( ) {
98
+ it ( "should throw an error when no server available" , async function ( ) {
99
99
const client = makeMockClient ( { userId : "@alice:example.com" , deviceId : "DEVICEID" , msc3886Enabled : false } ) ;
100
100
const simpleHttpTransport = new MSC3886SimpleHttpRendezvousTransport ( { client, fetchFn } ) ;
101
- expect ( simpleHttpTransport . send ( { } ) ) . rejects . toThrow ( "Invalid rendezvous URI" ) ;
101
+ await expect ( simpleHttpTransport . send ( { } ) ) . rejects . toThrow ( "Invalid rendezvous URI" ) ;
102
102
} ) ;
103
103
104
104
it ( "POST to fallback server" , async function ( ) {
@@ -130,15 +130,14 @@ describe("SimpleHttpRendezvousTransport", function () {
130
130
fetchFn,
131
131
} ) ;
132
132
const prom = simpleHttpTransport . send ( { } ) ;
133
- expect ( prom ) . rejects . toThrow ( ) ;
134
133
httpBackend . when ( "POST" , "https://fallbackserver/rz" ) . response = {
135
134
body : null ,
136
135
response : {
137
136
statusCode : 201 ,
138
137
headers : { } ,
139
138
} ,
140
139
} ;
141
- await httpBackend . flush ( "" ) ;
140
+ await Promise . all ( [ expect ( prom ) . rejects . toThrow ( ) , httpBackend . flush ( "" ) ] ) ;
142
141
} ) ;
143
142
144
143
it ( "POST with absolute path response" , async function ( ) {
@@ -364,7 +363,7 @@ describe("SimpleHttpRendezvousTransport", function () {
364
363
fallbackRzServer : "https://fallbackserver/rz" ,
365
364
fetchFn,
366
365
} ) ;
367
- expect ( simpleHttpTransport . details ( ) ) . rejects . toThrow ( ) ;
366
+ await expect ( simpleHttpTransport . details ( ) ) . rejects . toThrow ( ) ;
368
367
} ) ;
369
368
370
369
it ( "send after cancelled" , async function ( ) {
@@ -375,7 +374,7 @@ describe("SimpleHttpRendezvousTransport", function () {
375
374
fetchFn,
376
375
} ) ;
377
376
await simpleHttpTransport . cancel ( RendezvousFailureReason . UserDeclined ) ;
378
- expect ( simpleHttpTransport . send ( { } ) ) . resolves . toBeUndefined ( ) ;
377
+ await expect ( simpleHttpTransport . send ( { } ) ) . resolves . toBeUndefined ( ) ;
379
378
} ) ;
380
379
381
380
it ( "receive before ready" , async function ( ) {
@@ -385,7 +384,7 @@ describe("SimpleHttpRendezvousTransport", function () {
385
384
fallbackRzServer : "https://fallbackserver/rz" ,
386
385
fetchFn,
387
386
} ) ;
388
- expect ( simpleHttpTransport . receive ( ) ) . rejects . toThrow ( ) ;
387
+ await expect ( simpleHttpTransport . receive ( ) ) . rejects . toThrow ( ) ;
389
388
} ) ;
390
389
391
390
it ( "404 failure callback" , async function ( ) {
@@ -398,15 +397,17 @@ describe("SimpleHttpRendezvousTransport", function () {
398
397
onFailure,
399
398
} ) ;
400
399
401
- expect ( simpleHttpTransport . send ( { foo : "baa" } ) ) . resolves . toBeUndefined ( ) ;
402
400
httpBackend . when ( "POST" , "https://fallbackserver/rz" ) . response = {
403
401
body : null ,
404
402
response : {
405
403
statusCode : 404 ,
406
404
headers : { } ,
407
405
} ,
408
406
} ;
409
- await httpBackend . flush ( "" , 1 ) ;
407
+ await Promise . all ( [
408
+ expect ( simpleHttpTransport . send ( { foo : "baa" } ) ) . resolves . toBeUndefined ( ) ,
409
+ httpBackend . flush ( "" , 1 ) ,
410
+ ] ) ;
410
411
expect ( onFailure ) . toHaveBeenCalledWith ( RendezvousFailureReason . Unknown ) ;
411
412
} ) ;
412
413
@@ -438,15 +439,14 @@ describe("SimpleHttpRendezvousTransport", function () {
438
439
}
439
440
{
440
441
// GET with 404 to simulate expiry
441
- expect ( simpleHttpTransport . receive ( ) ) . resolves . toBeUndefined ( ) ;
442
442
httpBackend . when ( "GET" , "https://fallbackserver/rz/123" ) . response = {
443
443
body : { foo : "baa" } ,
444
444
response : {
445
445
statusCode : 404 ,
446
446
headers : { } ,
447
447
} ,
448
448
} ;
449
- await httpBackend . flush ( "" ) ;
449
+ await Promise . all ( [ expect ( simpleHttpTransport . receive ( ) ) . resolves . toBeUndefined ( ) , httpBackend . flush ( "" ) ] ) ;
450
450
expect ( onFailure ) . toHaveBeenCalledWith ( RendezvousFailureReason . Expired ) ;
451
451
}
452
452
} ) ;
0 commit comments