-
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.
feat: add parentComponent option (#846)
- Loading branch information
1 parent
5fecbd2
commit 1951409
Showing
11 changed files
with
96 additions
and
29 deletions.
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
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
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,35 @@ | ||
import { describeWithMountingMethods } from '~resources/utils' | ||
|
||
describeWithMountingMethods('options.parentComponent', mountingMethod => { | ||
it('mounts component with $parent set to options.parentComponent', () => { | ||
const Parent = { | ||
data: () => ({ | ||
customName: 'Parent Name' | ||
}) | ||
} | ||
const TestComponent = { | ||
template: '<div>{{$parent.customName}}</div>' | ||
} | ||
const wrapper = mountingMethod(TestComponent, { | ||
parentComponent: Parent | ||
}) | ||
const HTML = mountingMethod.name === 'renderToString' | ||
? wrapper | ||
: wrapper.html() | ||
expect(HTML).to.contain('Parent Name') | ||
}) | ||
|
||
it('validates parentComponent option', () => { | ||
;['str', 123, [], () => {}].forEach(invalidParent => { | ||
const TestComponent = { | ||
template: '<div>{{$parent.customName}}</div>' | ||
} | ||
const fn = () => mountingMethod(TestComponent, { | ||
parentComponent: invalidParent | ||
}) | ||
const message = '[vue-test-utils]: options.parentComponent should be a valid Vue component options object' | ||
expect(fn).to.throw() | ||
.with.property('message', message) | ||
}) | ||
}) | ||
}) |
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