@@ -1368,6 +1368,7 @@ describe('Composer & VueI18n extend hooking', () => {
1368
1368
const composerExtendSpy = jest
1369
1369
. fn ( )
1370
1370
. mockImplementation ( ( composer : Composer ) => {
1371
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1371
1372
; ( composer as any ) . foo = ref ( 'hello world' )
1372
1373
} )
1373
1374
const vueI18nExtendSpy = jest . fn ( )
@@ -1389,31 +1390,64 @@ describe('Composer & VueI18n extend hooking', () => {
1389
1390
pluginOptions : {
1390
1391
__composerExtend : composerExtendSpy ,
1391
1392
__vueI18nExtend : vueI18nExtendSpy
1392
- } as any
1393
+ } as any // eslint-disable-line @typescript-eslint/no-explicit-any
1393
1394
} )
1394
1395
expect ( composerExtendSpy ) . toHaveBeenCalled ( )
1395
1396
expect ( html ( ) ) . toBe ( '<p>hello world</p>' )
1396
1397
expect ( vueI18nExtendSpy ) . not . toHaveBeenCalled ( )
1397
1398
} )
1398
1399
1399
- test ( 'legacy' , async ( ) => {
1400
- const composerExtendSpy = jest . fn ( )
1401
- const vueI18nExtendSpy = jest
1402
- . fn ( )
1403
- . mockImplementation ( ( vueI18n : VueI18n ) => {
1404
- ; ( vueI18n as any ) . foo = 'hello world'
1400
+ describe ( 'legacy' , ( ) => {
1401
+ test ( 'basic' , async ( ) => {
1402
+ const composerExtendSpy = jest . fn ( )
1403
+ const vueI18nExtendSpy = jest
1404
+ . fn ( )
1405
+ . mockImplementation ( ( vueI18n : VueI18n ) => {
1406
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1407
+ ; ( vueI18n as any ) . foo = 'hello world'
1408
+ } )
1409
+ const i18n = createI18n ( { legacy : true } )
1410
+
1411
+ const App = defineComponent ( { template : '<p>{{ $i18n.foo }}</p>' } )
1412
+ const { html } = await mount ( App , i18n , {
1413
+ pluginOptions : {
1414
+ __composerExtend : composerExtendSpy ,
1415
+ __vueI18nExtend : vueI18nExtendSpy
1416
+ } as any // eslint-disable-line @typescript-eslint/no-explicit-any
1405
1417
} )
1406
- const i18n = createI18n ( { legacy : true } )
1418
+ expect ( composerExtendSpy ) . not . toHaveBeenCalled ( )
1419
+ expect ( vueI18nExtendSpy ) . toHaveBeenCalled ( )
1420
+ expect ( html ( ) ) . toBe ( '<p>hello world</p>' )
1421
+ } )
1407
1422
1408
- const App = defineComponent ( { template : '<p>{{ $i18n.foo }}</p>' } )
1409
- const { html } = await mount ( App , i18n , {
1410
- pluginOptions : {
1411
- __composerExtend : composerExtendSpy ,
1412
- __vueI18nExtend : vueI18nExtendSpy
1413
- } as any
1423
+ test ( 'use global vue i18n instance in components' , async ( ) => {
1424
+ const composerExtendSpy = jest . fn ( )
1425
+ const vueI18nExtendSpy = jest
1426
+ . fn ( )
1427
+ . mockImplementation ( ( vueI18n : VueI18n ) => {
1428
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1429
+ ; ( vueI18n as any ) . foo = 'hello world'
1430
+ } )
1431
+ const i18n = createI18n ( { legacy : true } )
1432
+
1433
+ const Child = defineComponent ( {
1434
+ template : '<span>{{ $i18n.foo }}</span>'
1435
+ } )
1436
+ const App = defineComponent ( {
1437
+ components : {
1438
+ Child
1439
+ } ,
1440
+ template : '<p>{{ $i18n.foo }}</p><Child />'
1441
+ } )
1442
+ const { html } = await mount ( App , i18n , {
1443
+ pluginOptions : {
1444
+ __composerExtend : composerExtendSpy ,
1445
+ __vueI18nExtend : vueI18nExtendSpy
1446
+ } as any // eslint-disable-line @typescript-eslint/no-explicit-any
1447
+ } )
1448
+ expect ( composerExtendSpy ) . not . toHaveBeenCalled ( )
1449
+ expect ( vueI18nExtendSpy ) . toHaveBeenCalledTimes ( 1 )
1450
+ expect ( html ( ) ) . toBe ( '<p>hello world</p><span>hello world</span>' )
1414
1451
} )
1415
- expect ( composerExtendSpy ) . not . toHaveBeenCalled ( )
1416
- expect ( vueI18nExtendSpy ) . toHaveBeenCalled ( )
1417
- expect ( html ( ) ) . toBe ( '<p>hello world</p>' )
1418
1452
} )
1419
1453
} )
0 commit comments