@@ -2,13 +2,13 @@ import React from 'react';
22
33import * as Hooks from '~/hooks' ;
44import * as Actions from '../actions' ;
5- import * as OtherLocales from '~/api/other-locales' ;
65import { BATCHACTIONS } from '../reducer' ;
76
87import { BatchActions } from './BatchActions' ;
98import { vi } from 'vitest' ;
109import { fireEvent , render } from '@testing-library/react' ;
1110import { MockLocalizationProvider } from '~/test/utils' ;
11+ import { PROJECT } from '~/modules/project' ;
1212
1313const DEFAULT_BATCH_ACTIONS = {
1414 entities : [ ] ,
@@ -17,20 +17,28 @@ const DEFAULT_BATCH_ACTIONS = {
1717 response : null ,
1818} ;
1919
20- vi . mock ( '~/hooks' , ( ) => ( {
21- useAppDispatch : vi . fn ( ( ) => vi . fn ( ) ) ,
22- useAppSelector : vi . fn ( ( selector ) =>
23- selector ( { [ BATCHACTIONS ] : DEFAULT_BATCH_ACTIONS } ) ,
24- ) ,
25- } ) ) ;
26-
2720vi . mock ( '../actions' , ( ) => ( {
2821 resetSelection : vi . fn ( ( ) => ( { type : 'whatever' } ) ) ,
2922 selectAll : vi . fn ( ( ) => ( { type : 'whatever' } ) ) ,
3023} ) ) ;
3124
32- vi . mock ( '~/api/other-locales' , ( ) => ( {
33- fetchAllLocales : vi . fn ( ( ) => Promise . resolve ( [ ] ) ) ,
25+ const DEFAULT_PROJECT_STATE = {
26+ fetching : false ,
27+ slug : '' ,
28+ name : '' ,
29+ info : '' ,
30+ tags : [ ] ,
31+ locales : [ ] ,
32+ } ;
33+
34+ vi . mock ( '~/hooks' , ( ) => ( {
35+ useAppDispatch : vi . fn ( ( ) => vi . fn ( ) ) ,
36+ useAppSelector : vi . fn ( ( selector ) =>
37+ selector ( {
38+ [ BATCHACTIONS ] : DEFAULT_BATCH_ACTIONS ,
39+ [ PROJECT ] : DEFAULT_PROJECT_STATE ,
40+ } ) ,
41+ ) ,
3442} ) ) ;
3543
3644describe ( '<BatchActions>' , ( ) => {
@@ -39,7 +47,6 @@ describe('<BatchActions>', () => {
3947 Hooks . useAppSelector . mockRestore ( ) ;
4048 Actions . resetSelection . mockRestore ( ) ;
4149 Actions . selectAll . mockRestore ( ) ;
42- OtherLocales . fetchAllLocales . mockClear ( ) ;
4350 } ) ;
4451
4552 const WrapBatchAction = ( ) => {
0 commit comments