-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: clone propsData to avoid mutation (#613)
- Loading branch information
1 parent
7c5a2dc
commit a93275c
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) | ||
}) |