File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ export function getRegisteredVueOrDefault(): VueConstructor {
46
46
}
47
47
48
48
export function setVueConstructor ( Vue : VueConstructor ) {
49
- if ( __DEV__ && vueConstructor ) {
49
+ // @ts -ignore
50
+ if ( __DEV__ && vueConstructor && Vue . __proto__ !== vueConstructor . __proto__ ) {
50
51
warn ( 'Another instance of vue installed' )
51
52
}
52
53
vueConstructor = Vue
Original file line number Diff line number Diff line change
1
+ import Vue from 'vue'
1
2
import CompositionApi from '../src'
2
3
import { createLocalVue } from './helpers/create-local-vue'
3
4
import { mockWarn } from './helpers'
@@ -12,7 +13,26 @@ describe('use', () => {
12
13
const localVueTwo = createLocalVue ( )
13
14
localVueTwo . use ( CompositionApi )
14
15
15
- expect ( 'Another instance of vue installed' ) . toHaveBeenWarned ( )
16
+ expect ( 'Another instance of vue installed' ) . not . toHaveBeenWarned ( )
17
+ } )
18
+
19
+ it ( 'should warn install in multiple vue' , ( ) => {
20
+ try {
21
+ const fakeVue = {
22
+ version : '2._.x' ,
23
+ config : {
24
+ optionMergeStrategies : { } ,
25
+ } ,
26
+ mixin : jest . fn ( ) ,
27
+ }
28
+
29
+ // @ts -ignore
30
+ CompositionApi . install ( fakeVue )
31
+ expect ( 'Another instance of vue installed' ) . toHaveBeenWarned ( )
32
+ } finally {
33
+ Vue . use ( CompositionApi )
34
+ expect ( 'Another instance of vue installed' ) . toHaveBeenWarned ( )
35
+ }
16
36
} )
17
37
18
38
it ( 'should warn installing multiple times' , ( ) => {
@@ -29,7 +49,5 @@ describe('use', () => {
29
49
} ) . toThrowError (
30
50
'already installed. Vue.use(VueCompositionAPI) should be called only once.'
31
51
)
32
-
33
- expect ( 'Another instance of vue installed' ) . toHaveBeenWarned ( )
34
52
} )
35
53
} )
You can’t perform that action at this time.
0 commit comments