@@ -2,6 +2,7 @@ import { compileToFunctions } from 'vue-template-compiler'
2
2
import ComponentWithProps from '~resources/components/component-with-props.vue'
3
3
import ComponentWithWatch from '~resources/components/component-with-watch.vue'
4
4
import { describeWithShallowAndMount , vueVersion } from '~resources/utils'
5
+ import { itDoNotRunIf } from 'conditional-specs'
5
6
6
7
describeWithShallowAndMount ( 'setProps' , mountingMethod => {
7
8
let info
@@ -38,18 +39,28 @@ describeWithShallowAndMount('setProps', mountingMethod => {
38
39
expect ( wrapper . is ( 'div' ) ) . to . equal ( true )
39
40
} )
40
41
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' , ( ) => {
42
43
const TestComponent = {
43
44
template : '<div></div>'
44
45
}
45
46
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`
47
48
const fn = ( ) => mountingMethod ( TestComponent ) . setProps ( { prop1 : 'prop' } )
48
49
expect ( fn )
49
50
. to . throw ( )
50
51
. with . property ( 'message' , message )
51
52
} )
52
53
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
+
53
64
it ( 'throws error when called on functional vnode' , ( ) => {
54
65
const AFunctionalComponent = {
55
66
render : ( h , context ) => h ( 'div' , context . prop1 ) ,
0 commit comments