File tree 2 files changed +35
-1
lines changed
test/specs/mounting-options
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export default function createInstance (
57
57
58
58
const Constructor = vue . extend ( component )
59
59
60
- const instanceOptions = { ...options }
60
+ const instanceOptions = { ...options , propsData : { ... options . propsData } }
61
61
deleteoptions ( instanceOptions )
62
62
// $FlowIgnore
63
63
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