1
1
import Vue from '@vue/compat'
2
2
import { effect , isReactive } from '@vue/reactivity'
3
- import { nextTick } from '@vue/runtime-core'
3
+ import { h , nextTick } from '@vue/runtime-core'
4
4
import {
5
5
DeprecationTypes ,
6
6
deprecationData ,
@@ -454,19 +454,51 @@ test('post-facto global asset registration should affect apps created via create
454
454
template : '<foo/>'
455
455
} )
456
456
Vue . component ( 'foo' , { template : 'foo' } )
457
- const vm = app . mount ( document . createElement ( 'div' ) ) as any ;
457
+ const vm = app . mount ( document . createElement ( 'div' ) ) as any
458
458
expect ( vm . $el . textContent ) . toBe ( 'foo' )
459
459
delete singletonApp . _context . components . foo
460
460
} )
461
461
462
462
test ( 'local asset registration should not affect other local apps' , ( ) => {
463
- const app1 = createApp ( { } ) ;
464
- const app2 = createApp ( { } ) ;
463
+ const app1 = createApp ( { } )
464
+ const app2 = createApp ( { } )
465
465
466
- app1 . component ( 'foo' , { } ) ;
467
- app2 . component ( 'foo' , { } ) ;
466
+ app1 . component ( 'foo' , { } )
467
+ app2 . component ( 'foo' , { } )
468
468
469
469
expect (
470
470
`Component "foo" has already been registered in target app`
471
471
) . not . toHaveBeenWarned ( )
472
- } )
472
+ } )
473
+
474
+ test ( 'local app-level mixin registration should not affect other local apps' , ( ) => {
475
+ const app1 = createApp ( { render : ( ) => h ( 'div' ) } )
476
+ const app2 = createApp ( { } )
477
+
478
+ const mixin = { created : jest . fn ( ) }
479
+ app1 . mixin ( mixin )
480
+ app2 . mixin ( mixin )
481
+
482
+ expect ( `Mixin has already been applied` ) . not . toHaveBeenWarned ( )
483
+
484
+ app1 . mount ( document . createElement ( 'div' ) )
485
+ expect ( mixin . created ) . toHaveBeenCalledTimes ( 1 )
486
+ } )
487
+
488
+ // #5699
489
+ test ( 'local app config should not affect other local apps in v3 mode' , ( ) => {
490
+ Vue . configureCompat ( { MODE : 3 } )
491
+ const app1 = createApp ( {
492
+ render : ( ) => h ( 'div' ) ,
493
+ provide ( ) {
494
+ return {
495
+ test : 123
496
+ }
497
+ }
498
+ } )
499
+ app1 . config . globalProperties . test = ( ) => { }
500
+ app1 . mount ( document . createElement ( 'div' ) )
501
+
502
+ const app2 = createApp ( { } )
503
+ expect ( app2 . config . globalProperties . test ) . toBe ( undefined )
504
+ } )
0 commit comments