@@ -18,6 +18,13 @@ describe('RecoveryDataComponent', () => {
1818 const email = '[email protected] ' ; 1919 const secret = new Uint8Array ( [ 1 , 2 , 3 ] ) ;
2020
21+ // Mock the anchor click to avoid interference with other tests
22+ const clickSpy = vi
23+ . spyOn ( HTMLAnchorElement . prototype as unknown as { click : ( ) => void } , 'click' )
24+ . mockImplementation ( ( ) => {
25+ // Mock implementation for testing. This is comment is to silence lint warnings
26+ } ) ;
27+
2128 render ( < RecoveryDataComponent email = { email } secret = { secret } show = { show } /> ) ;
2229
2330 expect ( screen . getByTestId ( 'modal-title' ) . textContent ) . toBe ( 'save_recovery_data' ) ;
@@ -51,13 +58,22 @@ describe('RecoveryDataComponent', () => {
5158
5259 fireEvent . click ( closeButton ) ;
5360 expect ( show . value ) . toBe ( false ) ;
61+
62+ clickSpy . mockRestore ( ) ;
5463 } ) ;
5564
5665 it ( 'prevents closing modal until file is saved and confirmed' , async ( ) => {
5766 const { RecoveryDataComponent } = await importComponent ( ) ;
5867
5968 const show = signal ( true ) ;
6069
70+ // Mock the anchor click to avoid interference with other tests
71+ const clickSpy = vi
72+ . spyOn ( HTMLAnchorElement . prototype as unknown as { click : ( ) => void } , 'click' )
73+ . mockImplementation ( ( ) => {
74+ // Mock implementation for testing. This is comment is to silence lint warnings
75+ } ) ;
76+
6177 render ( < RecoveryDataComponent email = { '[email protected] ' } secret = { new Uint8Array ( ) } show = { show } /> ) ; 6278
6379 // Try to close the modal without saving/confirming - should not close
@@ -81,9 +97,11 @@ describe('RecoveryDataComponent', () => {
8197 await waitFor ( ( ) => {
8298 expect ( closeButton ) . not . toBeDisabled ( ) ;
8399 } ) ;
84-
100+
85101 fireEvent . click ( closeButton ) ;
86102 expect ( show . value ) . toBe ( false ) ;
103+
104+ clickSpy . mockRestore ( ) ;
87105 } ) ;
88106} ) ;
89107
@@ -117,6 +135,11 @@ describe('saveRecoveryData', () => {
117135 expect ( clickSpy ) . toHaveBeenCalledTimes ( 1 ) ;
118136 expect ( revokeUrl ) . toHaveBeenCalledWith ( 'blob:test-url' ) ;
119137
120- expect ( window . crypto . subtle . digest ) . toHaveBeenCalledWith ( 'SHA-256' , expect . anything ( ) ) ;
138+ expect ( window . crypto . subtle . digest ) . toHaveBeenCalledWith ( 'SHA-256' , expect . anything ( ) ) ;
139+
140+ // Clean up spies
141+ createUrl . mockRestore ( ) ;
142+ clickSpy . mockRestore ( ) ;
143+ revokeUrl . mockRestore ( ) ;
121144 } ) ;
122145} ) ;
0 commit comments