@@ -2,6 +2,7 @@ import { compileToFunctions } from 'vue-template-compiler'
22import ComponentWithProps from '~resources/components/component-with-props.vue'
33import ComponentWithWatch from '~resources/components/component-with-watch.vue'
44import { describeWithShallowAndMount , vueVersion } from '~resources/utils'
5+ import { itDoNotRunIf } from 'conditional-specs'
56
67describeWithShallowAndMount ( 'setProps' , mountingMethod => {
78 let info
@@ -38,18 +39,28 @@ describeWithShallowAndMount('setProps', mountingMethod => {
3839 expect ( wrapper . is ( 'div' ) ) . to . equal ( true )
3940 } )
4041
41- it ( 'throws error if component does not include props key' , ( ) => {
42+ itDoNotRunIf ( vueVersion > 2.3 , 'throws error if component does not include props key' , ( ) => {
4243 const TestComponent = {
4344 template : '<div></div>'
4445 }
4546 const message = `[vue-test-utils]: wrapper.setProps() called ` +
46- `with prop1 property which is not defined on the component`
47+ `with prop1 property which is not defined on the component`
4748 const fn = ( ) => mountingMethod ( TestComponent ) . setProps ( { prop1 : 'prop' } )
4849 expect ( fn )
4950 . to . throw ( )
5051 . with . property ( 'message' , message )
5152 } )
5253
54+ itDoNotRunIf ( vueVersion < 2.4 , 'attributes not recognized as props are available via the $attrs instance property' , ( ) => {
55+ const TestComponent = {
56+ template : '<div></div>'
57+ }
58+ const prop1 = 'prop1'
59+ const wrapper = mountingMethod ( TestComponent )
60+ wrapper . setProps ( { prop1 } )
61+ expect ( wrapper . vm . $attrs . prop1 ) . to . equal ( prop1 )
62+ } )
63+
5364 it ( 'throws error when called on functional vnode' , ( ) => {
5465 const AFunctionalComponent = {
5566 render : ( h , context ) => h ( 'div' , context . prop1 ) ,
0 commit comments