File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
test/unit/features/options Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,9 @@ import {
25
25
export function initState ( vm : Component ) {
26
26
vm . _watchers = [ ]
27
27
initProps ( vm )
28
+ initMethods ( vm )
28
29
initData ( vm )
29
30
initComputed ( vm )
30
- initMethods ( vm )
31
31
initWatch ( vm )
32
32
}
33
33
Original file line number Diff line number Diff line change @@ -75,4 +75,34 @@ describe('Options data', () => {
75
75
vm . $data = { }
76
76
expect ( 'Avoid replacing instance root $data' ) . toHaveBeenWarned ( )
77
77
} )
78
+
79
+ it ( 'should have access to props' , ( ) => {
80
+ const Test = {
81
+ props : [ 'a' ] ,
82
+ data ( ) {
83
+ return {
84
+ b : this . a
85
+ }
86
+ }
87
+ }
88
+ const vm = new Vue ( {
89
+ template : `<test ref="test" :a="1"></test>` ,
90
+ components : { Test }
91
+ } ) . $mount ( )
92
+ expect ( vm . $refs . test . b ) . toBe ( 1 )
93
+ } )
94
+
95
+ it ( 'should have access to methods' , ( ) => {
96
+ const vm = new Vue ( {
97
+ methods : {
98
+ get ( ) {
99
+ return { a : 1 }
100
+ }
101
+ } ,
102
+ data ( ) {
103
+ return this . get ( )
104
+ }
105
+ } )
106
+ expect ( vm . a ) . toBe ( 1 )
107
+ } )
78
108
} )
You can’t perform that action at this time.
0 commit comments