1
1
import Vue from 'vue'
2
2
3
- describe ( 'Directive v- ref' , ( ) => {
3
+ describe ( 'ref' , ( ) => {
4
4
const components = {
5
5
test : {
6
6
id : 'test'
@@ -10,19 +10,22 @@ describe('Directive v-ref', () => {
10
10
}
11
11
}
12
12
13
- it ( 'should accept hyphenated refs ' , ( ) => {
13
+ it ( 'should work ' , ( ) => {
14
14
const vm = new Vue ( {
15
+ data : {
16
+ value : 'bar'
17
+ } ,
15
18
template : `<div>
16
- <test v- ref:test ></test>
17
- <test2 v-ref:test-hyphen ></test2>
19
+ <test ref="foo" ></test>
20
+ <test2 :ref="value" ></test2>
18
21
</div>` ,
19
22
components
20
23
} )
21
24
vm . $mount ( )
22
- expect ( vm . $refs . test ) . toBeTruthy ( )
23
- expect ( vm . $refs . test . $options . id ) . toBe ( 'test' )
24
- expect ( vm . $refs [ 'test-hyphen' ] ) . toBeTruthy ( )
25
- expect ( vm . $refs [ 'test-hyphen' ] . $options . id ) . toBe ( 'test2' )
25
+ expect ( vm . $refs . foo ) . toBeTruthy ( )
26
+ expect ( vm . $refs . foo . $options . id ) . toBe ( 'test' )
27
+ expect ( vm . $refs . bar ) . toBeTruthy ( )
28
+ expect ( vm . $refs . bar . $options . id ) . toBe ( 'test2' )
26
29
} )
27
30
28
31
it ( 'should work as a hyperscript prop' , ( ) => {
@@ -39,25 +42,9 @@ describe('Directive v-ref', () => {
39
42
expect ( vm . $refs . test . $options . id ) . toBe ( 'test' )
40
43
} )
41
44
42
- it ( 'should accept camelCase refs' , ( ) => {
43
- const vm = new Vue ( {
44
- template :
45
- `<div>
46
- <test v-ref:test></test>
47
- <test2 v-ref:testCase></test2>
48
- </div>` ,
49
- components
50
- } )
51
- vm . $mount ( )
52
- expect ( vm . $refs . test ) . toBeTruthy ( )
53
- expect ( vm . $refs . test . $options . id ) . toBe ( 'test' )
54
- expect ( vm . $refs . testCase ) . toBeTruthy ( )
55
- expect ( vm . $refs . testCase . $options . id ) . toBe ( 'test2' )
56
- } )
57
-
58
45
it ( 'should accept HOC component' , ( ) => {
59
46
const vm = new Vue ( {
60
- template : '<test v- ref: test></test>' ,
47
+ template : '<test ref=" test" ></test>' ,
61
48
components
62
49
} )
63
50
vm . $mount ( )
@@ -68,7 +55,7 @@ describe('Directive v-ref', () => {
68
55
it ( 'should accept dynamic component' , done => {
69
56
const vm = new Vue ( {
70
57
template : `<div>
71
- <component :is="test" v- ref: test></component>
58
+ <component :is="test" ref=" test" ></component>
72
59
</div>` ,
73
60
components,
74
61
data : { test : 'test' }
@@ -91,7 +78,7 @@ describe('Directive v-ref', () => {
91
78
} ,
92
79
template : `
93
80
<div>
94
- <div v-for="n in items" v- ref: list>{{n}}</div>
81
+ <div v-for="n in items" ref=" list" >{{n}}</div>
95
82
</div>
96
83
`
97
84
} ) . $mount ( )
@@ -117,7 +104,7 @@ describe('Directive v-ref', () => {
117
104
} ,
118
105
template : `
119
106
<div>
120
- <test v-for="n in items" v- ref: list :n="n"></test>
107
+ <test v-for="n in items" ref=" list" :n="n"></test>
121
108
</div>
122
109
` ,
123
110
components : {
0 commit comments