@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import { type Mocked , type SpyInstance } from "jest-mock" ;
17+ import { type Mocked } from "jest-mock" ;
1818import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm" ;
1919import { type OlmMachine } from "@matrix-org/matrix-sdk-crypto-wasm" ;
2020import fetchMock from "fetch-mock-jest" ;
@@ -211,14 +211,14 @@ describe("PerSessionKeyBackupDownloader", () => {
211211 fetchMock . get ( `path:/_matrix/client/v3/room_keys/keys/!roomA/sessionA1` , mockCipherKey ) ;
212212
213213 // @ts -ignore access to private function
214- const spy : SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
214+ const spy : jest . SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
215215
216216 const expectImported = expectSessionImported ( "!roomA" , "sessionA1" ) ;
217217
218218 downloader . onDecryptionKeyMissingError ( "!roomA" , "sessionA0" ) ;
219219 await jest . runAllTimersAsync ( ) ;
220220 expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
221- expect ( spy ) . toHaveLastReturnedWith ( Promise . resolve ( { ok : false , error : "MISSING_DECRYPTION_KEY" } ) ) ;
221+ await expect ( spy . mock . results [ 0 ] . value ) . rejects . toThrow ( "MISSING_DECRYPTION_KEY" ) ;
222222
223223 downloader . onDecryptionKeyMissingError ( "!roomA" , "sessionA1" ) ;
224224 await jest . runAllTimersAsync ( ) ;
@@ -237,7 +237,7 @@ describe("PerSessionKeyBackupDownloader", () => {
237237 } ) ;
238238
239239 // @ts -ignore access to private function
240- const spy : SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
240+ const spy : jest . SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
241241
242242 downloader . onDecryptionKeyMissingError ( "!roomA" , "sessionA0" ) ;
243243 await jest . runAllTimersAsync ( ) ;
@@ -297,7 +297,7 @@ describe("PerSessionKeyBackupDownloader", () => {
297297 } ) ;
298298
299299 describe ( "Given no usable backup available" , ( ) => {
300- let getConfigSpy : SpyInstance ;
300+ let getConfigSpy : jest . SpyInstance ;
301301
302302 beforeEach ( async ( ) => {
303303 mockRustBackupManager . getActiveBackupVersion . mockResolvedValue ( null ) ;
@@ -318,7 +318,7 @@ describe("PerSessionKeyBackupDownloader", () => {
318318 await jest . runAllTimersAsync ( ) ;
319319
320320 expect ( getConfigSpy ) . toHaveBeenCalledTimes ( 1 ) ;
321- expect ( getConfigSpy ) . toHaveReturnedWith ( Promise . resolve ( null ) ) ;
321+ await expect ( getConfigSpy . mock . results [ 0 ] . value ) . resolves . toEqual ( null ) ;
322322
323323 // isKeyBackupDownloadConfigured remains false
324324 expect ( downloader . isKeyBackupDownloadConfigured ( ) ) . toBe ( false ) ;
@@ -336,7 +336,7 @@ describe("PerSessionKeyBackupDownloader", () => {
336336 await jest . runAllTimersAsync ( ) ;
337337
338338 expect ( getConfigSpy ) . toHaveBeenCalledTimes ( 1 ) ;
339- expect ( getConfigSpy ) . toHaveReturnedWith ( Promise . resolve ( null ) ) ;
339+ await expect ( getConfigSpy . mock . results [ 0 ] . value ) . resolves . toEqual ( null ) ;
340340
341341 // isKeyBackupDownloadConfigured remains false
342342 expect ( downloader . isKeyBackupDownloadConfigured ( ) ) . toBe ( false ) ;
@@ -355,7 +355,7 @@ describe("PerSessionKeyBackupDownloader", () => {
355355 await jest . runAllTimersAsync ( ) ;
356356
357357 expect ( getConfigSpy ) . toHaveBeenCalledTimes ( 1 ) ;
358- expect ( getConfigSpy ) . toHaveReturnedWith ( Promise . resolve ( null ) ) ;
358+ await expect ( getConfigSpy . mock . results [ 0 ] . value ) . resolves . toEqual ( null ) ;
359359
360360 // isKeyBackupDownloadConfigured remains false
361361 expect ( downloader . isKeyBackupDownloadConfigured ( ) ) . toBe ( false ) ;
@@ -377,7 +377,7 @@ describe("PerSessionKeyBackupDownloader", () => {
377377 await jest . runAllTimersAsync ( ) ;
378378
379379 expect ( getConfigSpy ) . toHaveBeenCalledTimes ( 1 ) ;
380- expect ( getConfigSpy ) . toHaveReturnedWith ( Promise . resolve ( null ) ) ;
380+ await expect ( getConfigSpy . mock . results [ 0 ] . value ) . resolves . toEqual ( null ) ;
381381
382382 // isKeyBackupDownloadConfigured remains false
383383 expect ( downloader . isKeyBackupDownloadConfigured ( ) ) . toBe ( false ) ;
@@ -399,7 +399,7 @@ describe("PerSessionKeyBackupDownloader", () => {
399399 await jest . runAllTimersAsync ( ) ;
400400
401401 expect ( getConfigSpy ) . toHaveBeenCalledTimes ( 1 ) ;
402- expect ( getConfigSpy ) . toHaveReturnedWith ( Promise . resolve ( null ) ) ;
402+ await expect ( getConfigSpy . mock . results [ 0 ] . value ) . resolves . toEqual ( null ) ;
403403
404404 // isKeyBackupDownloadConfigured remains false
405405 expect ( downloader . isKeyBackupDownloadConfigured ( ) ) . toBe ( false ) ;
@@ -488,7 +488,7 @@ describe("PerSessionKeyBackupDownloader", () => {
488488 const originalImplementation = downloader . queryKeyBackup . bind ( downloader ) ;
489489
490490 // @ts -ignore access to private function
491- const keyQuerySpy : SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
491+ const keyQuerySpy : jest . SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
492492 const rateDeferred = Promise . withResolvers < void > ( ) ;
493493
494494 keyQuerySpy . mockImplementation (
@@ -542,7 +542,7 @@ describe("PerSessionKeyBackupDownloader", () => {
542542 const originalImplementation = downloader . queryKeyBackup . bind ( downloader ) ;
543543
544544 // @ts -ignore
545- const keyQuerySpy : SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
545+ const keyQuerySpy : jest . SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
546546 const errorDeferred = Promise . withResolvers < void > ( ) ;
547547
548548 keyQuerySpy . mockImplementation (
@@ -606,7 +606,7 @@ describe("PerSessionKeyBackupDownloader", () => {
606606 } ) ;
607607
608608 // @ts -ignore access to private function
609- const keyQuerySpy : SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
609+ const keyQuerySpy : jest . SpyInstance = jest . spyOn ( downloader , "queryKeyBackup" ) ;
610610
611611 downloader . onDecryptionKeyMissingError ( "!roomA" , "sessionA0" ) ;
612612 downloader . onDecryptionKeyMissingError ( "!roomA" , "sessionA1" ) ;
0 commit comments