Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flow/options.flow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare type Options = { // eslint-disable-line no-undef
attachToDocument?: boolean,
propsData?: Object,
mocks?: Object,
methods?: Object,
slots?: Object,
Expand Down
2 changes: 1 addition & 1 deletion packages/create-instance/create-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function createInstance (

const Constructor = vue.extend(component)

const instanceOptions = { ...options }
const instanceOptions = { ...options, propsData: { ...options.propsData }}
deleteoptions(instanceOptions)
// $FlowIgnore
const stubComponents = createComponentStubs(component.components, options.stubs)
Expand Down
34 changes: 34 additions & 0 deletions test/specs/mounting-options/propsData.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { shallowMount } from '~vue/test-utils'
import ComponentWithProps from '~resources/components/component-with-props.vue'
import { describeIf } from '~resources/utils'

const baseData = {
prop1: ['', '']
}

describeIf(process.env.TEST_ENV !== 'node',
'propsData', () => {
let wrapper

beforeEach(() => {
wrapper = shallowMount(ComponentWithProps, {
propsData: baseData
})
})

afterEach(() => {
wrapper = null
})

describe('should not modify propsData between tests', () => {
it('should have the correct props after modifying', () => {
expect(wrapper.vm.prop1).to.have.length(2)
wrapper.setProps({ prop1: [] })
expect(wrapper.vm.prop1).to.have.length(0)
})

it('should have the default props despite being modified in the previous test', () => {
expect(wrapper.vm.prop1).to.have.length(2)
})
})
})