@@ -2,6 +2,10 @@ import { describe, expect, test, it, vi } from 'vitest'
2
2
import { h , App } from 'vue'
3
3
4
4
import { mount } from '../../src'
5
+ import ScriptSetup from '../components/ScriptSetup.vue'
6
+ import Option from '../components/OptionComponent.vue'
7
+ import OptionsSetup from '../components/OptionSetupComponent.vue'
8
+ import OptionsSetupWithoutReturn from '../components/OptionSetupWithoutReturnComponent.vue'
5
9
6
10
describe ( 'mounting options: plugins' , ( ) => {
7
11
it ( 'installs a plugin via `plugins`' , ( ) => {
@@ -51,6 +55,41 @@ describe('mounting options: plugins', () => {
51
55
52
56
expect ( installed ) . toHaveBeenCalledWith ( options , testString )
53
57
} )
58
+
59
+ describe ( 'provides access to a global property' , ( ) => {
60
+ class Plugin {
61
+ static install ( app : App ) {
62
+ app . config . globalProperties . foo = 'bar'
63
+ }
64
+ }
65
+ it ( 'provides access to a global property from a Composition API component' , ( ) => {
66
+ const wrapper = mount ( ScriptSetup , {
67
+ global : { plugins : [ Plugin ] }
68
+ } )
69
+ expect ( ( wrapper . vm as any ) . foo ) . toBeDefined ( )
70
+ } )
71
+
72
+ it ( 'provides access to a global property from an Options API component' , ( ) => {
73
+ const wrapper = mount ( Option , {
74
+ global : { plugins : [ Plugin ] }
75
+ } )
76
+ expect ( ( wrapper . vm as any ) . foo ) . toBeDefined ( )
77
+ } )
78
+
79
+ it ( 'provides access to a global property from an Options API component with a setup() function' , ( ) => {
80
+ const wrapper = mount ( OptionsSetup , {
81
+ global : { plugins : [ Plugin ] }
82
+ } )
83
+ expect ( ( wrapper . vm as any ) . foo ) . toBeDefined ( )
84
+ } )
85
+
86
+ it ( 'provides access to a global property from an Options API component with a setup() function that does not return' , ( ) => {
87
+ const wrapper = mount ( OptionsSetupWithoutReturn , {
88
+ global : { plugins : [ Plugin ] }
89
+ } )
90
+ expect ( ( wrapper . vm as any ) . foo ) . toBeDefined ( )
91
+ } )
92
+ } )
54
93
} )
55
94
56
95
test ( 'installs plugins with and without options' , ( ) => {
0 commit comments