11import Vue from 'vue'
22
3- describe ( 'Directive v- ref' , ( ) => {
3+ describe ( 'ref' , ( ) => {
44 const components = {
55 test : {
66 id : 'test'
@@ -10,19 +10,22 @@ describe('Directive v-ref', () => {
1010 }
1111 }
1212
13- it ( 'should accept hyphenated refs ' , ( ) => {
13+ it ( 'should work ' , ( ) => {
1414 const vm = new Vue ( {
15+ data : {
16+ value : 'bar'
17+ } ,
1518 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>
1821 </div>` ,
1922 components
2023 } )
2124 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' )
2629 } )
2730
2831 it ( 'should work as a hyperscript prop' , ( ) => {
@@ -39,25 +42,9 @@ describe('Directive v-ref', () => {
3942 expect ( vm . $refs . test . $options . id ) . toBe ( 'test' )
4043 } )
4144
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-
5845 it ( 'should accept HOC component' , ( ) => {
5946 const vm = new Vue ( {
60- template : '<test v- ref: test></test>' ,
47+ template : '<test ref=" test" ></test>' ,
6148 components
6249 } )
6350 vm . $mount ( )
@@ -68,7 +55,7 @@ describe('Directive v-ref', () => {
6855 it ( 'should accept dynamic component' , done => {
6956 const vm = new Vue ( {
7057 template : `<div>
71- <component :is="test" v- ref: test></component>
58+ <component :is="test" ref=" test" ></component>
7259 </div>` ,
7360 components,
7461 data : { test : 'test' }
@@ -91,7 +78,7 @@ describe('Directive v-ref', () => {
9178 } ,
9279 template : `
9380 <div>
94- <div v-for="n in items" v- ref: list>{{n}}</div>
81+ <div v-for="n in items" ref=" list" >{{n}}</div>
9582 </div>
9683 `
9784 } ) . $mount ( )
@@ -117,7 +104,7 @@ describe('Directive v-ref', () => {
117104 } ,
118105 template : `
119106 <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>
121108 </div>
122109 ` ,
123110 components : {
0 commit comments