File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
test/specs/mounting-options Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 11declare type Options = { // eslint-disable-line no-undef
22 attachToDocument ?: boolean ,
3+ propsData ?: Object ,
34 mocks ?: Object ,
45 methods ?: Object ,
56 slots ?: Object ,
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export default function createInstance (
5757
5858 const Constructor = vue . extend ( component )
5959
60- const instanceOptions = { ...options }
60+ const instanceOptions = { ...options , propsData : { ... options . propsData } }
6161 deleteoptions ( instanceOptions )
6262 // $FlowIgnore
6363 const stubComponents = createComponentStubs ( component . components , options . stubs )
Original file line number Diff line number Diff line change 1+ import { shallowMount } from '~vue/test-utils'
2+ import ComponentWithProps from '~resources/components/component-with-props.vue'
3+ import { describeIf } from '~resources/utils'
4+
5+ const baseData = {
6+ prop1 : [ '' , '' ]
7+ }
8+
9+ describeIf ( process . env . TEST_ENV !== 'node' ,
10+ 'propsData' , ( ) => {
11+ let wrapper
12+
13+ beforeEach ( ( ) => {
14+ wrapper = shallowMount ( ComponentWithProps , {
15+ propsData : baseData
16+ } )
17+ } )
18+
19+ afterEach ( ( ) => {
20+ wrapper = null
21+ } )
22+
23+ describe ( 'should not modify propsData between tests' , ( ) => {
24+ it ( 'should have the correct props after modifying' , ( ) => {
25+ expect ( wrapper . vm . prop1 ) . to . have . length ( 2 )
26+ wrapper . setProps ( { prop1 : [ ] } )
27+ expect ( wrapper . vm . prop1 ) . to . have . length ( 0 )
28+ } )
29+
30+ it ( 'should have the default props despite being modified in the previous test' , ( ) => {
31+ expect ( wrapper . vm . prop1 ) . to . have . length ( 2 )
32+ } )
33+ } )
34+ } )
You can’t perform that action at this time.
0 commit comments