@@ -3,6 +3,7 @@ import { expect } from 'chai';
3
3
import 'mocha' ;
4
4
import { Component , Provide , Base , Inject , toNative } from '../../dist'
5
5
import { VueWrapper , mount } from '@vue/test-utils' ;
6
+ import { Ref , computed , ref } from 'vue' ;
6
7
7
8
describe ( 'decorator Provide' ,
8
9
( ) => {
@@ -14,13 +15,18 @@ describe('decorator Provide',
14
15
} )
15
16
class Parent extends Base {
16
17
@Provide
17
- readonly foo = 'provided foo'
18
+ foo = 'provided foo'
18
19
19
20
@Provide
20
21
readonly foo2 = this . foo
21
22
22
23
@Provide ( 'overridden' )
23
24
readonly _internalName = 123
25
+
26
+ @Provide
27
+ get getter ( ) {
28
+ return 'from getter'
29
+ }
24
30
}
25
31
26
32
@Component ( { template : '<span />' } )
@@ -36,8 +42,12 @@ describe('decorator Provide',
36
42
37
43
@Inject
38
44
readonly overridden ! : number
45
+
46
+ @Inject
47
+ readonly getter ! : string
39
48
}
40
49
50
+ let parent : VueWrapper < Parent > ;
41
51
let child : VueWrapper < Child > ;
42
52
43
53
beforeEach ( ( ) => {
@@ -51,7 +61,14 @@ describe('decorator Provide',
51
61
Parent,
52
62
Child,
53
63
}
64
+ } , {
65
+ global : {
66
+ config : {
67
+ unwrapInjectedRef : true ,
68
+ } ,
69
+ } ,
54
70
} )
71
+ parent = component . findComponent ( Parent )
55
72
child = component . findComponent ( Child )
56
73
} )
57
74
@@ -72,6 +89,18 @@ describe('decorator Provide',
72
89
expect ( child . vm . overridden ) . to . equal ( 123 )
73
90
} )
74
91
92
+ it ( 'getter' , ( ) => {
93
+ expect ( child . vm . getter ) . to . equal ( 'from getter' )
94
+ } )
95
+
96
+ it ( 'honours reactivity' , async ( ) => {
97
+ expect ( parent . vm . foo ) . to . equal ( 'provided foo' )
98
+ expect ( child . vm . foo ) . to . equal ( 'provided foo' )
99
+
100
+ parent . vm . foo = 'bar'
101
+ expect ( child . vm . foo ) . to . equal ( 'bar' )
102
+ } )
103
+
75
104
it ( 'prioritises the class decorator' , ( ) => {
76
105
@Component ( {
77
106
template : '<div><slot/></div>' ,
0 commit comments