@@ -117,7 +117,7 @@ describe('i18n hook', () => {
117117 const spy = vi . spyOn ( console , 'error' )
118118 spy . mockImplementation ( ( ) => { } )
119119
120- expect ( ( ) => renderHook ( ( ) => useTranslation ( ) ) ) . toThrow (
120+ expect ( ( ) => renderHook ( ( ) => useTranslation ( [ 'test' ] ) ) ) . toThrow (
121121 new Error ( 'useTranslation must be used within a I18nProvider' ) ,
122122 )
123123 spy . mockRestore ( )
@@ -133,34 +133,41 @@ describe('i18n hook', () => {
133133 spy . mockRestore ( )
134134 } )
135135
136- it ( 'should use defaultLoad, useTranslation, switch local and translate' , async ( ) => {
137- const { result } = renderHook ( ( ) => useTranslation < Locale , Locales > ( [ ] ) , {
138- wrapper : wrapper ( { defaultLocale : 'en' } ) ,
139- } )
140- // first render there is no load
141- expect ( result . current . t ( 'title' ) ) . toEqual ( '' )
136+ it (
137+ 'should use defaultLoad, useTranslation, switch local and translate' ,
138+ async ( ) => {
139+ const { result } = renderHook (
140+ ( ) => useTranslation < Locale , Locales > ( [ 'test' ] ) ,
141+ {
142+ wrapper : wrapper ( { defaultLocale : 'en' } ) ,
143+ } ,
144+ )
145+ // first render there is no load
146+ expect ( result . current . t ( 'title' ) ) . toEqual ( '' )
142147
143- await waitFor ( ( ) => {
144- // after load of en locale
145- expect ( result . current . t ( 'title' ) ) . toEqual ( en . title )
146- } )
148+ await waitFor ( ( ) => {
149+ // after load of en locale
150+ expect ( result . current . t ( 'title' ) ) . toEqual ( en . title )
151+ } )
147152
148- await act ( async ( ) => {
149- await result . current . switchLocale ( 'fr' )
150- } )
153+ await act ( async ( ) => {
154+ await result . current . switchLocale ( 'fr' )
155+ } )
151156
152- await waitFor ( ( ) => {
153- expect ( result . current . t ( 'title' ) ) . toEqual ( fr . title )
154- } )
157+ await waitFor ( ( ) => {
158+ expect ( result . current . t ( 'title' ) ) . toEqual ( fr . title )
159+ } )
155160
156- await act ( async ( ) => {
157- await result . current . switchLocale ( 'es' )
158- } )
161+ await act ( async ( ) => {
162+ await result . current . switchLocale ( 'es' )
163+ } )
159164
160- await waitFor ( ( ) => {
161- expect ( result . current . t ( 'title' ) ) . toEqual ( es . title )
162- } )
163- } )
165+ await waitFor ( ( ) => {
166+ expect ( result . current . t ( 'title' ) ) . toEqual ( es . title )
167+ } )
168+ } ,
169+ { } ,
170+ )
164171
165172 it ( 'should use specific load on useTranslation' , async ( ) => {
166173 const { result } = renderHook (
@@ -262,7 +269,8 @@ describe('i18n hook', () => {
262269
263270 it ( 'should work with a component' , async ( ) => {
264271 const { result } = renderHook (
265- ( ) => useTranslation < { 'with.identifier' : 'Hello {identifier}' } > ( [ ] ) ,
272+ ( ) =>
273+ useTranslation < { 'with.identifier' : 'Hello {identifier}' } > ( [ 'test' ] ) ,
266274 {
267275 wrapper : wrapper ( { defaultLocale : 'en' } ) ,
268276 } ,
0 commit comments