@@ -139,7 +139,7 @@ describe("MatrixClient", function() {
139139 path : string ,
140140 queryParams ?: QueryDict ,
141141 body ?: Body ,
142- requestOpts : IRequestOpts = { }
142+ requestOpts : IRequestOpts = { } ,
143143 ) {
144144 const { prefix } = requestOpts ;
145145 if ( path === KEEP_ALIVE_PATH && acceptKeepalives ) {
@@ -205,9 +205,22 @@ describe("MatrixClient", function() {
205205 }
206206 return Promise . resolve ( next . data ) ;
207207 }
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+ ) ;
208223 // 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 ) ;
211224 throw new Error (
212225 `A pending request was not handled: ${ receivedRequest } ` +
213226 `(next request expected was ${ expectedRequest } )\n` +
@@ -286,7 +299,7 @@ describe("MatrixClient", function() {
286299 data : { event_id : eventId } ,
287300 expectQueryParams : {
288301 ts : '0' ,
289- dir : 'f'
302+ dir : 'f' ,
290303 } ,
291304 } ] ;
292305
@@ -297,11 +310,11 @@ describe("MatrixClient", function() {
297310 expect ( method ) . toStrictEqual ( 'GET' ) ;
298311 expect ( prefix ) . toStrictEqual ( ClientPrefix . V1 ) ;
299312 expect ( path ) . toStrictEqual (
300- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
313+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
301314 ) ;
302315 expect ( queryParams ) . toStrictEqual ( {
303316 ts : '0' ,
304- dir : 'f'
317+ dir : 'f' ,
305318 } ) ;
306319 } ) ;
307320
@@ -312,11 +325,11 @@ describe("MatrixClient", function() {
312325 prefix : ClientPrefix . V1 ,
313326 error : {
314327 httpStatus : 404 ,
315- errcode : "M_UNRECOGNIZED"
328+ errcode : "M_UNRECOGNIZED" ,
316329 } ,
317330 expectQueryParams : {
318331 ts : '0' ,
319- dir : 'f'
332+ dir : 'f' ,
320333 } ,
321334 } , {
322335 method : "GET" ,
@@ -325,33 +338,45 @@ describe("MatrixClient", function() {
325338 data : { event_id : eventId } ,
326339 expectQueryParams : {
327340 ts : '0' ,
328- dir : 'f'
341+ dir : 'f' ,
329342 } ,
330343 } ] ;
331344
332345 await client . timestampToEvent ( roomId , 0 , 'f' ) ;
333346
334347 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 ] ;
336355 expect ( stableMethod ) . toStrictEqual ( 'GET' ) ;
337356 expect ( stablePrefix ) . toStrictEqual ( ClientPrefix . V1 ) ;
338357 expect ( stablePath ) . toStrictEqual (
339- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
358+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
340359 ) ;
341360 expect ( stableQueryParams ) . toStrictEqual ( {
342361 ts : '0' ,
343- dir : 'f'
362+ dir : 'f' ,
344363 } ) ;
345364
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 ] ;
347372 expect ( unstableMethod ) . toStrictEqual ( 'GET' ) ;
348373 expect ( unstablePrefix ) . toStrictEqual ( unstableMsc3030Prefix ) ;
349374 expect ( unstablePath ) . toStrictEqual (
350- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
375+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
351376 ) ;
352377 expect ( unstableQueryParams ) . toStrictEqual ( {
353378 ts : '0' ,
354- dir : 'f'
379+ dir : 'f' ,
355380 } ) ;
356381 } ) ;
357382
@@ -362,11 +387,11 @@ describe("MatrixClient", function() {
362387 prefix : ClientPrefix . V1 ,
363388 error : {
364389 httpStatus : 500 ,
365- errcode : "Fake response error"
390+ errcode : "Fake response error" ,
366391 } ,
367392 expectQueryParams : {
368393 ts : '0' ,
369- dir : 'f'
394+ dir : 'f' ,
370395 } ,
371396 } ] ;
372397
@@ -377,11 +402,11 @@ describe("MatrixClient", function() {
377402 expect ( method ) . toStrictEqual ( 'GET' ) ;
378403 expect ( prefix ) . toStrictEqual ( ClientPrefix . V1 ) ;
379404 expect ( path ) . toStrictEqual (
380- `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event`
405+ `/rooms/${ encodeURIComponent ( roomId ) } /timestamp_to_event` ,
381406 ) ;
382407 expect ( queryParams ) . toStrictEqual ( {
383408 ts : '0' ,
384- dir : 'f'
409+ dir : 'f' ,
385410 } ) ;
386411 } ) ;
387412 } ) ;
0 commit comments