@@ -33,7 +33,7 @@ describeWithShallowAndMount('setData', mountingMethod => {
33
33
const wrapper = mountingMethod ( Component )
34
34
wrapper . setData ( { show : true } )
35
35
expect ( wrapper . element ) . to . equal ( wrapper . vm . $el )
36
- expect ( wrapper . hasClass ( 'some-class' ) ) . to . be . true
36
+ expect ( wrapper . classes ( ) ) . to . contain ( 'some-class' )
37
37
} )
38
38
39
39
it ( 'runs watch function when data is updated' , ( ) => {
@@ -117,7 +117,7 @@ describeWithShallowAndMount('setData', mountingMethod => {
117
117
expect ( wrapper . vm . basket [ 0 ] ) . to . equal ( 'hello' )
118
118
} )
119
119
120
- it . skip ( 'should not run watcher if data is null' , ( ) => {
120
+ it ( 'should not run watcher if data is null' , ( ) => {
121
121
const TestComponent = {
122
122
template : `
123
123
<div>
@@ -217,4 +217,50 @@ describeWithShallowAndMount('setData', mountingMethod => {
217
217
expect ( wrapper . text ( ) ) . to . equal ( '10' )
218
218
expect ( wrapper . vm . nested . nested . nestedArray ) . to . deep . equal ( [ 10 ] )
219
219
} )
220
+
221
+ it ( 'should append a new property to an object when the new property is referenced by a template' , ( ) => {
222
+ const TestComponent = {
223
+ data : ( ) => ( {
224
+ anObject : {
225
+ propA : 'a' ,
226
+ propB : 'b'
227
+ }
228
+ } ) ,
229
+ computed : {
230
+ anObjectKeys ( ) {
231
+ return Object . keys ( this . anObject ) . join ( ',' )
232
+ }
233
+ } ,
234
+ template : `<div>{{ anObjectKeys }}</div>`
235
+ }
236
+ const wrapper = mountingMethod ( TestComponent )
237
+ wrapper . setData ( {
238
+ anObject : {
239
+ propC : 'c'
240
+ }
241
+ } )
242
+
243
+ expect ( wrapper . vm . anObject . propA ) . to . equal ( 'a' )
244
+ expect ( wrapper . vm . anObject . propB ) . to . equal ( 'b' )
245
+ expect ( wrapper . vm . anObject . propC ) . to . equal ( 'c' )
246
+ expect ( wrapper . vm . anObjectKeys ) . to . equal ( 'propA,propB,propC' )
247
+ expect ( wrapper . html ( ) ) . to . equal ( '<div>propA,propB,propC</div>' )
248
+ } )
249
+
250
+ it ( 'allows setting data of type Date synchronously' , ( ) => {
251
+ const TestComponent = {
252
+ template : `
253
+ <div>
254
+ {{selectedDate}}
255
+ </div>
256
+ ` ,
257
+ data : ( ) => ( {
258
+ selectedDate : undefined
259
+ } )
260
+ }
261
+ const testDate = new Date ( )
262
+ const wrapper = mountingMethod ( TestComponent )
263
+ wrapper . setData ( { selectedDate : testDate } )
264
+ expect ( wrapper . vm . selectedDate ) . to . equal ( testDate )
265
+ } )
220
266
} )
0 commit comments