forked from vuejs/vue-test-utils
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test-utils): add 'overview' function
close vuejs#1461
- Loading branch information
root
authored and
root
committed
Mar 28, 2020
1 parent
228cd1a
commit 61ee2c9
Showing
6 changed files
with
458 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## overview | ||
|
||
Prints a simple overview of the `Wrapper`. | ||
|
||
- **Example:** | ||
|
||
```js | ||
import { mount } from '@vue/test-utils' | ||
import Component from './Component.vue' | ||
|
||
const wrapper = mount(Component) | ||
wrapper.overview() | ||
|
||
// Console output | ||
/* | ||
Wrapper (Visible): | ||
Html: | ||
<div class="test"> | ||
<p>My name is Tess Ting</p> | ||
</div> | ||
Data: { | ||
firstName: Tess, | ||
lastName: Ting | ||
} | ||
Computed: { | ||
fullName: Tess Ting' | ||
} | ||
Emitted: {', | ||
foo: [', | ||
0: [ hello, world ], | ||
1: [ bye, world ]' | ||
], | ||
bar: [ | ||
0: [ hey ]' | ||
] | ||
} | ||
*/ | ||
``` |
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,24 @@ | ||
import { describeWithShallowAndMount } from '~resources/utils' | ||
import { compileToFunctions } from 'vue-template-compiler' | ||
import '@vue/test-utils' | ||
|
||
describeWithShallowAndMount('overview', mountingMethod => { | ||
it('throws error if wrapper array contains no items', () => { | ||
const wrapper = mountingMethod(compileToFunctions('<div />')) | ||
const message = '[vue-test-utils]: overview() cannot be called on 0 items' | ||
|
||
expect(() => wrapper.findAll('p').overview()) | ||
.to.throw() | ||
.with.property('message', message) | ||
}) | ||
|
||
it('throws error when called on a WrapperArray', () => { | ||
const wrapper = mountingMethod(compileToFunctions('<div><div /></div>')) | ||
const message = | ||
'[vue-test-utils]: overview() must be called on a single wrapper, use at(i) to access a wrapper' | ||
|
||
expect(() => wrapper.findAll('div').overview()) | ||
.to.throw() | ||
.with.property('message', message) | ||
}) | ||
}) |
Oops, something went wrong.