@@ -4,9 +4,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
44
55import { useUserMFAService } from '@/hooks/my-account/use-user-mfa-service' ;
66import * as useCoreClientModule from '@/hooks/shared/use-core-client' ;
7- import * as useErrorHandlerModule from '@/hooks/shared/use-error-handler' ;
8- import * as useTranslatorModule from '@/hooks/shared/use-translator' ;
9- import { mockCore , setupAllCommonMocks , createQueryClientWrapper } from '@/tests/utils' ;
7+ import { mockCore , setupMockUseCoreClient , createQueryClientWrapper } from '@/tests/utils' ;
108
119const { initMockCoreClient } = mockCore ( ) ;
1210let mockCoreClient : ReturnType < typeof initMockCoreClient > ;
@@ -15,12 +13,7 @@ describe('useUserMFAService', () => {
1513 beforeEach ( ( ) => {
1614 vi . clearAllMocks ( ) ;
1715 mockCoreClient = initMockCoreClient ( ) ;
18- setupAllCommonMocks ( {
19- coreClient : mockCoreClient ,
20- useCoreClientModule,
21- useTranslatorModule,
22- useErrorHandlerModule,
23- } ) ;
16+ setupMockUseCoreClient ( mockCoreClient , useCoreClientModule ) ;
2417 } ) ;
2518
2619 const renderService = ( onlyActive = false ) => {
@@ -69,14 +62,13 @@ describe('useUserMFAService', () => {
6962 it ( 'calls authenticationMethods.delete and invalidates query on success' , async ( ) => {
7063 const apiClient = mockCoreClient . getMyAccountApiClient ( ) ;
7164
72- const { result, rerender } = renderService ( ) ;
65+ const { result } = renderService ( ) ;
7366 await waitFor ( ( ) => expect ( result . current . factorsQuery . isSuccess ) . toBe ( true ) ) ;
7467
7568 const initialCallCount = vi . mocked ( apiClient . factors . list ) . mock . calls . length ;
7669 await result . current . deleteMutation . mutateAsync ( 'auth-id-123' ) ;
7770
7871 expect ( apiClient . authenticationMethods . delete ) . toHaveBeenCalledWith ( 'auth-id-123' ) ;
79- rerender ( ) ;
8072 await waitFor ( ( ) => {
8173 expect ( vi . mocked ( apiClient . factors . list ) . mock . calls . length ) . toBeGreaterThan ( initialCallCount ) ;
8274 } ) ;
0 commit comments