@@ -33,7 +33,7 @@ describeWithShallowAndMount('setData', mountingMethod => {
3333 const wrapper = mountingMethod ( Component )
3434 wrapper . setData ( { show : true } )
3535 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' )
3737 } )
3838
3939 it ( 'runs watch function when data is updated' , ( ) => {
@@ -117,7 +117,7 @@ describeWithShallowAndMount('setData', mountingMethod => {
117117 expect ( wrapper . vm . basket [ 0 ] ) . to . equal ( 'hello' )
118118 } )
119119
120- it . skip ( 'should not run watcher if data is null' , ( ) => {
120+ it ( 'should not run watcher if data is null' , ( ) => {
121121 const TestComponent = {
122122 template : `
123123 <div>
@@ -217,4 +217,50 @@ describeWithShallowAndMount('setData', mountingMethod => {
217217 expect ( wrapper . text ( ) ) . to . equal ( '10' )
218218 expect ( wrapper . vm . nested . nested . nestedArray ) . to . deep . equal ( [ 10 ] )
219219 } )
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+ } )
220266} )
0 commit comments