Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: does not pass data provided to mount to wrapper component
- Loading branch information
Showing
3 changed files
with
28 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,24 @@ | ||
import { describeWithShallowAndMount } from '~resources/utils' | ||
|
||
describeWithShallowAndMount('options.data', mountingMethod => { | ||
const TestComponent = { | ||
data: () => ({ foo: 1, bar: 2 }), | ||
template: '<div />' | ||
} | ||
|
||
it('correctly merges component data and data passed to mount', () => { | ||
const wrapper = mountingMethod(TestComponent, { data: () => ({ foo: 3 }) }) | ||
|
||
expect(wrapper.vm.foo).toBe(3) | ||
expect(wrapper.vm.bar).toBe(2) | ||
}) | ||
|
||
it('does not fail when data is extracted to local variable', () => { | ||
const defaultData = { foo: 3 } | ||
|
||
const wrapper = mountingMethod(TestComponent, { data: () => defaultData }) | ||
|
||
expect(wrapper.vm.foo).toBe(3) | ||
expect(wrapper.vm.bar).toBe(2) | ||
}) | ||
}) |