Skip to content

Commit 47fd65e

Browse files
author
Alexandre St-Louis Fortier
committed
test(mounting-options): test propsData containing a 'child' attribute
1 parent 1415b84 commit 47fd65e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/specs/mounting-options/propsData.spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,38 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'propsData', () => {
3131
})
3232
})
3333
})
34+
35+
const Component = {
36+
template: '<div>{{ child }}</div>',
37+
props: ['child']
38+
}
39+
40+
const childData = {
41+
child: 'aBc'
42+
}
43+
44+
describeRunIf(process.env.TEST_ENV !== 'node', 'propsData {child}', () => {
45+
let wrapper
46+
47+
beforeEach(() => {
48+
wrapper = shallowMount(Component, {
49+
propsData: childData
50+
})
51+
})
52+
53+
afterEach(() => {
54+
wrapper = null
55+
})
56+
57+
describe('should not modify propsData between tests', () => {
58+
it('should have the correct props after modifying', async () => {
59+
expect(wrapper.vm.child).toHaveLength(3)
60+
await wrapper.setProps({ child: '' })
61+
expect(wrapper.vm.child).toHaveLength(0)
62+
})
63+
64+
it('should have the default props despite being modified in the previous test', () => {
65+
expect(wrapper.vm.child).toHaveLength(3)
66+
})
67+
})
68+
})

0 commit comments

Comments
 (0)