@@ -305,7 +305,7 @@ describe('MatrixClient', () => {
305
305
306
306
describe ( 'getServerVersions' , ( ) => {
307
307
it ( 'should call the right endpoint' , async ( ) => {
308
- const { client, http } = createTestClient ( ) ;
308
+ const { client, http } = createTestClient ( undefined , undefined , undefined , { handleWhoAmI : true , precacheVersions : false } ) ;
309
309
310
310
const versionsResponse : ServerVersions = {
311
311
unstable_features : {
@@ -322,7 +322,7 @@ describe('MatrixClient', () => {
322
322
} ) ;
323
323
324
324
it ( 'should cache the response' , async ( ) => {
325
- const { client, http } = createTestClient ( ) ;
325
+ const { client, http } = createTestClient ( undefined , undefined , undefined , { handleWhoAmI : true , precacheVersions : false } ) ;
326
326
327
327
const versionsResponse : ServerVersions = {
328
328
unstable_features : {
@@ -358,7 +358,7 @@ describe('MatrixClient', () => {
358
358
[ { "org.example.wrong" : true } , "org.example.feature" , false ] ,
359
359
[ { "org.example.wrong" : false } , "org.example.feature" , false ] ,
360
360
] ) ( "should find that %p has %p as %p" , async ( versions , flag , target ) => {
361
- const { client, http } = createTestClient ( ) ;
361
+ const { client, http } = createTestClient ( undefined , undefined , undefined , { handleWhoAmI : true , precacheVersions : false } ) ;
362
362
363
363
const versionsResponse : ServerVersions = {
364
364
versions : [ "v1.1" ] ,
@@ -378,7 +378,7 @@ describe('MatrixClient', () => {
378
378
[ [ "v1.2" ] , "v1.1" , false ] ,
379
379
[ [ "v1.1" , "v1.2" , "v1.3" ] , "v1.2" , true ] ,
380
380
] ) ( "should find that %p has %p as %p" , async ( versions , version , target ) => {
381
- const { client, http } = createTestClient ( ) ;
381
+ const { client, http } = createTestClient ( undefined , undefined , undefined , { handleWhoAmI : true , precacheVersions : false } ) ;
382
382
383
383
const versionsResponse : ServerVersions = {
384
384
versions : versions ,
@@ -397,7 +397,7 @@ describe('MatrixClient', () => {
397
397
[ [ "v1.3" ] , [ "v1.1" , "v1.2" ] , false ] ,
398
398
[ [ "v1.1" , "v1.2" , "v1.3" ] , [ "v1.2" , "v1.3" ] , true ] ,
399
399
] ) ( "should find that %p has %p as %p" , async ( versions , searchVersions , target ) => {
400
- const { client, http } = createTestClient ( ) ;
400
+ const { client, http } = createTestClient ( undefined , undefined , undefined , { handleWhoAmI : true , precacheVersions : false } ) ;
401
401
402
402
const versionsResponse : ServerVersions = {
403
403
versions : versions ,
@@ -5646,8 +5646,8 @@ describe('MatrixClient', () => {
5646
5646
const mediaId = "testing/val" ;
5647
5647
const mxc = `mxc://${ domain } /${ mediaId } ` ;
5648
5648
5649
- const http = client . mxcToHttp ( mxc ) ;
5650
- expect ( http ) . toBe ( `${ hsUrl } /_matrix/media/v3 /download/${ encodeURIComponent ( domain ) } /${ encodeURIComponent ( mediaId ) } ` ) ;
5649
+ const http = await client . mxcToHttp ( mxc ) ;
5650
+ expect ( http ) . toBe ( `${ hsUrl } /_matrix/client/v1/media /download/${ encodeURIComponent ( domain ) } /${ encodeURIComponent ( mediaId ) } ` ) ;
5651
5651
} ) ;
5652
5652
5653
5653
it ( 'should error for non-MXC URIs' , async ( ) => {
@@ -5658,7 +5658,7 @@ describe('MatrixClient', () => {
5658
5658
const mxc = `https://${ domain } /${ mediaId } ` ;
5659
5659
5660
5660
try {
5661
- client . mxcToHttp ( mxc ) ;
5661
+ await client . mxcToHttp ( mxc ) ;
5662
5662
5663
5663
// noinspection ExceptionCaughtLocallyJS
5664
5664
throw new Error ( "Expected an error and didn't get one" ) ;
@@ -5679,9 +5679,9 @@ describe('MatrixClient', () => {
5679
5679
const method = "scale" ;
5680
5680
const mxc = `mxc://${ domain } /${ mediaId } ` ;
5681
5681
5682
- const http = client . mxcToHttpThumbnail ( mxc , width , height , method ) ;
5682
+ const http = await client . mxcToHttpThumbnail ( mxc , width , height , method ) ;
5683
5683
// eslint-disable-next-line max-len
5684
- expect ( http ) . toBe ( `${ hsUrl } /_matrix/media/v3 /thumbnail/${ encodeURIComponent ( domain ) } /${ encodeURIComponent ( mediaId ) } ?width=${ width } &height=${ height } &method=${ encodeURIComponent ( method ) } ` ) ;
5684
+ expect ( http ) . toBe ( `${ hsUrl } /_matrix/client/v1/media /thumbnail/${ encodeURIComponent ( domain ) } /${ encodeURIComponent ( mediaId ) } ?width=${ width } &height=${ height } &method=${ encodeURIComponent ( method ) } ` ) ;
5685
5685
} ) ;
5686
5686
5687
5687
it ( 'should error for non-MXC URIs' , async ( ) => {
@@ -5695,7 +5695,7 @@ describe('MatrixClient', () => {
5695
5695
const mxc = `https://${ domain } /${ mediaId } ` ;
5696
5696
5697
5697
try {
5698
- client . mxcToHttpThumbnail ( mxc , width , height , method ) ;
5698
+ await client . mxcToHttpThumbnail ( mxc , width , height , method ) ;
5699
5699
5700
5700
// noinspection ExceptionCaughtLocallyJS
5701
5701
throw new Error ( "Expected an error and didn't get one" ) ;
@@ -5717,7 +5717,7 @@ describe('MatrixClient', () => {
5717
5717
Buffer . isBuffer = < any > ( i => i === data ) ;
5718
5718
5719
5719
// noinspection TypeScriptValidateJSTypes
5720
- http . when ( "POST" , "/_matrix/media/v3 /upload" ) . respond ( 200 , ( path , content , req ) => {
5720
+ http . when ( "POST" , "/_matrix/client/v1/media /upload" ) . respond ( 200 , ( path , content , req ) => {
5721
5721
expect ( content ) . toBeDefined ( ) ;
5722
5722
expect ( req . queryParams . filename ) . toEqual ( filename ) ;
5723
5723
expect ( req . headers [ "Content-Type" ] ) . toEqual ( contentType ) ;
@@ -5740,7 +5740,7 @@ describe('MatrixClient', () => {
5740
5740
Buffer . isBuffer = < any > ( i => i === data ) ;
5741
5741
5742
5742
// noinspection TypeScriptValidateJSTypes
5743
- http . when ( "POST" , "/_matrix/media/v3 /upload" ) . respond ( 200 , ( path , content , req ) => {
5743
+ http . when ( "POST" , "/_matrix/client/v1/media /upload" ) . respond ( 200 , ( path , content , req ) => {
5744
5744
expect ( content ) . toBeDefined ( ) ;
5745
5745
expect ( req . queryParams . filename ) . toEqual ( filename ) ;
5746
5746
expect ( req . headers [ "Content-Type" ] ) . toEqual ( contentType ) ;
@@ -5761,8 +5761,8 @@ describe('MatrixClient', () => {
5761
5761
// const fileContents = Buffer.from("12345");
5762
5762
5763
5763
// noinspection TypeScriptValidateJSTypes
5764
- http . when ( "GET" , "/_matrix/media/v3 /download/" ) . respond ( 200 , ( path , _ , req ) => {
5765
- expect ( path ) . toContain ( "/_matrix/media/v3 /download/" + urlPart ) ;
5764
+ http . when ( "GET" , "/_matrix/client/v1/media /download/" ) . respond ( 200 , ( path , _ , req ) => {
5765
+ expect ( path ) . toContain ( "/_matrix/client/v1/media /download/" + urlPart ) ;
5766
5766
expect ( ( req as any ) . opts . encoding ) . toEqual ( null ) ;
5767
5767
// TODO: Honestly, I have no idea how to coerce the mock library to return headers or buffers,
5768
5768
// so this is left as a fun activity.
@@ -5798,7 +5798,7 @@ describe('MatrixClient', () => {
5798
5798
} ) ;
5799
5799
5800
5800
// noinspection TypeScriptValidateJSTypes
5801
- http . when ( "POST" , "/_matrix/media/v3 /upload" ) . respond ( 200 , ( path , content , req ) => {
5801
+ http . when ( "POST" , "/_matrix/client/v1/media /upload" ) . respond ( 200 , ( path , content , req ) => {
5802
5802
expect ( content ) . toBeDefined ( ) ;
5803
5803
// HACK: We know the mock library will return JSON
5804
5804
expect ( req . headers [ "Content-Type" ] ) . toEqual ( "application/json" ) ;
0 commit comments