forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpropsData.spec.js
34 lines (28 loc) · 925 Bytes
/
propsData.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { shallowMount } from '~vue/test-utils'
import ComponentWithProps from '~resources/components/component-with-props.vue'
import { describeRunIf } from 'conditional-specs'
const baseData = {
prop1: ['', '']
}
describeRunIf(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)
})
})
})