@@ -40,19 +40,20 @@ describe("AccessSecretStorageDialog", function() {
4040 testInstance . getInstance ( ) . _onRecoveryKeyNext ( e ) ;
4141 } ) ;
4242
43- it ( "Considers a valid key to be valid" , function ( ) {
43+ it ( "Considers a valid key to be valid" , async function ( ) {
4444 const testInstance = TestRenderer . create (
4545 < AccessSecretStorageDialog
4646 checkPrivateKey = { ( ) => true }
4747 /> ,
4848 ) ;
49- const v = "asfd " ;
49+ const v = "asdf " ;
5050 const e = { target : { value : v } } ;
5151 stubClient ( ) ;
52- MatrixClientPeg . get ( ) . isValidRecoveryKey = function ( k ) {
53- return k == v ;
54- } ;
52+ MatrixClientPeg . get ( ) . keyBackupKeyFromRecoveryKey = ( ) => 'a raw key' ;
53+ MatrixClientPeg . get ( ) . checkSecretStorageKey = ( ) => true ;
5554 testInstance . getInstance ( ) . _onRecoveryKeyChange ( e ) ;
55+ // force a validation now because it debounces
56+ await testInstance . getInstance ( ) . _validateRecoveryKey ( ) ;
5657 const { recoveryKeyValid } = testInstance . getInstance ( ) . state ;
5758 expect ( recoveryKeyValid ) . toBe ( true ) ;
5859 } ) ;
@@ -65,17 +66,20 @@ describe("AccessSecretStorageDialog", function() {
6566 ) ;
6667 const e = { target : { value : "a" } } ;
6768 stubClient ( ) ;
68- MatrixClientPeg . get ( ) . isValidRecoveryKey = ( ) => true ;
69+ MatrixClientPeg . get ( ) . keyBackupKeyFromRecoveryKey = ( ) => {
70+ throw new Error ( "that's no key" ) ;
71+ } ;
6972 testInstance . getInstance ( ) . _onRecoveryKeyChange ( e ) ;
70- await testInstance . getInstance ( ) . _onRecoveryKeyNext ( { preventDefault : ( ) => { } } ) ;
71- const { keyMatches } = testInstance . getInstance ( ) . state ;
72- expect ( keyMatches ) . toBe ( false ) ;
73+ // force a validation now because it debounces
74+ await testInstance . getInstance ( ) . _validateRecoveryKey ( ) ;
75+
76+ const { recoveryKeyValid, recoveryKeyCorrect } = testInstance . getInstance ( ) . state ;
77+ expect ( recoveryKeyValid ) . toBe ( false ) ;
78+ expect ( recoveryKeyCorrect ) . toBe ( false ) ;
7379 const notification = testInstance . root . findByProps ( {
74- className : "mx_AccessSecretStorageDialog_keyStatus " ,
80+ className : "mx_AccessSecretStorageDialog_recoveryKeyFeedback mx_AccessSecretStorageDialog_recoveryKeyFeedback_invalid " ,
7581 } ) ;
76- expect ( notification . props . children ) . toEqual (
77- [ "\uD83D\uDC4E " , "Unable to access secret storage. Please verify that you " +
78- "entered the correct recovery key." ] ) ;
82+ expect ( notification . props . children ) . toEqual ( "Invalid Recovery Key" ) ;
7983 done ( ) ;
8084 } ) ;
8185
0 commit comments