@@ -139,7 +139,7 @@ describe("MatrixClient", function() {
139
139
path : string ,
140
140
queryParams ?: QueryDict ,
141
141
body ?: Body ,
142
- requestOpts : IRequestOpts = { }
142
+ requestOpts : IRequestOpts = { } ,
143
143
) {
144
144
const { prefix } = requestOpts ;
145
145
if ( path === KEEP_ALIVE_PATH && acceptKeepalives ) {
@@ -205,9 +205,22 @@ describe("MatrixClient", function() {
205
205
}
206
206
return Promise . resolve ( next . data ) ;
207
207
}
208
+
209
+ const receivedRequestQueryString = new URLSearchParams (
210
+ convertQueryDictToStringRecord ( queryParams ) ,
211
+ ) . toString ( ) ;
212
+ const receivedRequest = decorateStringWithAnsiColor (
213
+ `${ method } ${ prefix } ${ path } ${ receivedRequestQueryString } ` ,
214
+ AnsiColorCode . Red ,
215
+ ) ;
216
+ const expectedQueryString = new URLSearchParams (
217
+ convertQueryDictToStringRecord ( next . expectQueryParams ) ,
218
+ ) . toString ( ) ;
219
+ const expectedRequest = decorateStringWithAnsiColor (
220
+ `${ next . method } ${ next . prefix ?? '' } ${ next . path } ${ expectedQueryString } ` ,
221
+ AnsiColorCode . Green ,
222
+ ) ;
208
223
// If you're seeing this then you forgot to handle at least 1 pending request.
209
- const receivedRequest = decorateStringWithAnsiColor ( `${ method } ${ prefix } ${ path } ${ new URLSearchParams ( convertQueryDictToStringRecord ( queryParams ) ) . toString ( ) } ` , AnsiColorCode . Red ) ;
210
- const expectedRequest = decorateStringWithAnsiColor ( `${ next . method } ${ next . prefix ?? '' } ${ next . path } ${ new URLSearchParams ( convertQueryDictToStringRecord ( next . expectQueryParams ) ) . toString ( ) } ` , AnsiColorCode . Green ) ;
211
224
throw new Error (
212
225
`A pending request was not handled: ${ receivedRequest } ` +
213
226
`(next request expected was ${ expectedRequest } )\n` +
@@ -286,7 +299,7 @@ describe("MatrixClient", function() {
286
299
data : { event_id : eventId } ,
287
300
expectQueryParams : {
288
301
ts : '0' ,
289
- dir : 'f'
302
+ dir : 'f' ,
290
303
} ,
291
304
} ] ;
292
305
@@ -297,11 +310,11 @@ describe("MatrixClient", function() {
297
310
expect ( method ) . toStrictEqual ( 'GET' ) ;
298
311
expect ( prefix ) . toStrictEqual ( ClientPrefix . V1 ) ;
299
312
expect ( path ) . toStrictEqual (
300
- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
313
+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
301
314
) ;
302
315
expect ( queryParams ) . toStrictEqual ( {
303
316
ts : '0' ,
304
- dir : 'f'
317
+ dir : 'f' ,
305
318
} ) ;
306
319
} ) ;
307
320
@@ -312,11 +325,11 @@ describe("MatrixClient", function() {
312
325
prefix : ClientPrefix . V1 ,
313
326
error : {
314
327
httpStatus : 404 ,
315
- errcode : "M_UNRECOGNIZED"
328
+ errcode : "M_UNRECOGNIZED" ,
316
329
} ,
317
330
expectQueryParams : {
318
331
ts : '0' ,
319
- dir : 'f'
332
+ dir : 'f' ,
320
333
} ,
321
334
} , {
322
335
method : "GET" ,
@@ -325,33 +338,45 @@ describe("MatrixClient", function() {
325
338
data : { event_id : eventId } ,
326
339
expectQueryParams : {
327
340
ts : '0' ,
328
- dir : 'f'
341
+ dir : 'f' ,
329
342
} ,
330
343
} ] ;
331
344
332
345
await client . timestampToEvent ( roomId , 0 , 'f' ) ;
333
346
334
347
expect ( client . http . authedRequest . mock . calls . length ) . toStrictEqual ( 2 ) ;
335
- const [ stableMethod , stablePath , stableQueryParams , , { prefix : stablePrefix } ] = client . http . authedRequest . mock . calls [ 0 ] ;
348
+ const [
349
+ stableMethod ,
350
+ stablePath ,
351
+ stableQueryParams ,
352
+ ,
353
+ { prefix : stablePrefix } ,
354
+ ] = client . http . authedRequest . mock . calls [ 0 ] ;
336
355
expect ( stableMethod ) . toStrictEqual ( 'GET' ) ;
337
356
expect ( stablePrefix ) . toStrictEqual ( ClientPrefix . V1 ) ;
338
357
expect ( stablePath ) . toStrictEqual (
339
- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
358
+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
340
359
) ;
341
360
expect ( stableQueryParams ) . toStrictEqual ( {
342
361
ts : '0' ,
343
- dir : 'f'
362
+ dir : 'f' ,
344
363
} ) ;
345
364
346
- const [ unstableMethod , unstablePath , unstableQueryParams , , { prefix : unstablePrefix } ] = client . http . authedRequest . mock . calls [ 1 ] ;
365
+ const [
366
+ unstableMethod ,
367
+ unstablePath ,
368
+ unstableQueryParams ,
369
+ ,
370
+ { prefix : unstablePrefix } ,
371
+ ] = client . http . authedRequest . mock . calls [ 1 ] ;
347
372
expect ( unstableMethod ) . toStrictEqual ( 'GET' ) ;
348
373
expect ( unstablePrefix ) . toStrictEqual ( unstableMsc3030Prefix ) ;
349
374
expect ( unstablePath ) . toStrictEqual (
350
- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
375
+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
351
376
) ;
352
377
expect ( unstableQueryParams ) . toStrictEqual ( {
353
378
ts : '0' ,
354
- dir : 'f'
379
+ dir : 'f' ,
355
380
} ) ;
356
381
} ) ;
357
382
@@ -362,11 +387,11 @@ describe("MatrixClient", function() {
362
387
prefix : ClientPrefix . V1 ,
363
388
error : {
364
389
httpStatus : 500 ,
365
- errcode : "Fake response error"
390
+ errcode : "Fake response error" ,
366
391
} ,
367
392
expectQueryParams : {
368
393
ts : '0' ,
369
- dir : 'f'
394
+ dir : 'f' ,
370
395
} ,
371
396
} ] ;
372
397
@@ -377,11 +402,11 @@ describe("MatrixClient", function() {
377
402
expect ( method ) . toStrictEqual ( 'GET' ) ;
378
403
expect ( prefix ) . toStrictEqual ( ClientPrefix . V1 ) ;
379
404
expect ( path ) . toStrictEqual (
380
- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
405
+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
381
406
) ;
382
407
expect ( queryParams ) . toStrictEqual ( {
383
408
ts : '0' ,
384
- dir : 'f'
409
+ dir : 'f' ,
385
410
} ) ;
386
411
} ) ;
387
412
} ) ;
0 commit comments