@@ -56,6 +56,7 @@ describe('Directive v-model checkbox', () => {
56
56
} ,
57
57
template : `
58
58
<div>
59
+ {{ test }}
59
60
<input type="checkbox" v-model="test" value="1">
60
61
<input type="checkbox" v-model="test" value="2">
61
62
</div>
@@ -65,13 +66,16 @@ describe('Directive v-model checkbox', () => {
65
66
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
66
67
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
67
68
vm . $el . children [ 0 ] . click ( )
68
- expect ( vm . test . length ) . toBe ( 0 )
69
- vm . $el . children [ 1 ] . click ( )
70
- expect ( vm . test ) . toEqual ( [ '2' ] )
71
- vm . $el . children [ 0 ] . click ( )
72
- expect ( vm . test ) . toEqual ( [ '2' , '1' ] )
73
- vm . test = [ '1' ]
74
69
waitForUpdate ( ( ) => {
70
+ expect ( vm . test . length ) . toBe ( 0 )
71
+ vm . $el . children [ 1 ] . click ( )
72
+ } ) . then ( ( ) => {
73
+ expect ( vm . test ) . toEqual ( [ '2' ] )
74
+ vm . $el . children [ 0 ] . click ( )
75
+ } ) . then ( ( ) => {
76
+ expect ( vm . test ) . toEqual ( [ '2' , '1' ] )
77
+ vm . test = [ '1' ]
78
+ } ) . then ( ( ) => {
75
79
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
76
80
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
77
81
} ) . then ( done )
@@ -93,13 +97,16 @@ describe('Directive v-model checkbox', () => {
93
97
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
94
98
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
95
99
vm . $el . children [ 0 ] . click ( )
96
- expect ( vm . test . length ) . toBe ( 0 )
97
- vm . $el . children [ 1 ] . click ( )
98
- expect ( vm . test ) . toEqual ( [ '2' ] )
99
- vm . $el . children [ 0 ] . click ( )
100
- expect ( vm . test ) . toEqual ( [ '2' , '1' ] )
101
- vm . test = [ '1' ]
102
100
waitForUpdate ( ( ) => {
101
+ expect ( vm . test . length ) . toBe ( 0 )
102
+ vm . $el . children [ 1 ] . click ( )
103
+ } ) . then ( ( ) => {
104
+ expect ( vm . test ) . toEqual ( [ '2' ] )
105
+ vm . $el . children [ 0 ] . click ( )
106
+ } ) . then ( ( ) => {
107
+ expect ( vm . test ) . toEqual ( [ '2' , '1' ] )
108
+ vm . test = [ '1' ]
109
+ } ) . then ( ( ) => {
103
110
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
104
111
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
105
112
} ) . then ( done )
@@ -121,13 +128,16 @@ describe('Directive v-model checkbox', () => {
121
128
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
122
129
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
123
130
vm . $el . children [ 0 ] . click ( )
124
- expect ( vm . test . length ) . toBe ( 0 )
125
- vm . $el . children [ 1 ] . click ( )
126
- expect ( vm . test ) . toEqual ( [ 2 ] )
127
- vm . $el . children [ 0 ] . click ( )
128
- expect ( vm . test ) . toEqual ( [ 2 , 1 ] )
129
- vm . test = [ 1 ]
130
131
waitForUpdate ( ( ) => {
132
+ expect ( vm . test . length ) . toBe ( 0 )
133
+ vm . $el . children [ 1 ] . click ( )
134
+ } ) . then ( ( ) => {
135
+ expect ( vm . test ) . toEqual ( [ 2 ] )
136
+ vm . $el . children [ 0 ] . click ( )
137
+ } ) . then ( ( ) => {
138
+ expect ( vm . test ) . toEqual ( [ 2 , 1 ] )
139
+ vm . test = [ 1 ]
140
+ } ) . then ( ( ) => {
131
141
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
132
142
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
133
143
} ) . then ( done )
@@ -149,13 +159,16 @@ describe('Directive v-model checkbox', () => {
149
159
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
150
160
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
151
161
vm . $el . children [ 0 ] . click ( )
152
- expect ( vm . test . length ) . toBe ( 0 )
153
- vm . $el . children [ 1 ] . click ( )
154
- expect ( vm . test ) . toEqual ( [ { a : 2 } ] )
155
- vm . $el . children [ 0 ] . click ( )
156
- expect ( vm . test ) . toEqual ( [ { a : 2 } , { a : 1 } ] )
157
- vm . test = [ { a : 1 } ]
158
162
waitForUpdate ( ( ) => {
163
+ expect ( vm . test . length ) . toBe ( 0 )
164
+ vm . $el . children [ 1 ] . click ( )
165
+ } ) . then ( ( ) => {
166
+ expect ( vm . test ) . toEqual ( [ { a : 2 } ] )
167
+ vm . $el . children [ 0 ] . click ( )
168
+ } ) . then ( ( ) => {
169
+ expect ( vm . test ) . toEqual ( [ { a : 2 } , { a : 1 } ] )
170
+ vm . test = [ { a : 1 } ]
171
+ } ) . then ( ( ) => {
159
172
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
160
173
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
161
174
} ) . then ( done )
@@ -177,13 +190,16 @@ describe('Directive v-model checkbox', () => {
177
190
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
178
191
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
179
192
vm . $el . children [ 0 ] . click ( )
180
- expect ( vm . test . length ) . toBe ( 0 )
181
- vm . $el . children [ 1 ] . click ( )
182
- expect ( vm . test ) . toEqual ( [ [ 2 ] ] )
183
- vm . $el . children [ 0 ] . click ( )
184
- expect ( vm . test ) . toEqual ( [ [ 2 ] , { a : 1 } ] )
185
- vm . test = [ { a : 1 } ]
186
193
waitForUpdate ( ( ) => {
194
+ expect ( vm . test . length ) . toBe ( 0 )
195
+ vm . $el . children [ 1 ] . click ( )
196
+ } ) . then ( ( ) => {
197
+ expect ( vm . test ) . toEqual ( [ [ 2 ] ] )
198
+ vm . $el . children [ 0 ] . click ( )
199
+ } ) . then ( ( ) => {
200
+ expect ( vm . test ) . toEqual ( [ [ 2 ] , { a : 1 } ] )
201
+ vm . test = [ { a : 1 } ]
202
+ } ) . then ( ( ) => {
187
203
expect ( vm . $el . children [ 0 ] . checked ) . toBe ( true )
188
204
expect ( vm . $el . children [ 1 ] . checked ) . toBe ( false )
189
205
} ) . then ( done )
0 commit comments