Skip to content

fix #1793 (Add WrapperArray#exists docs) #1795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/wrapper-array/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A `WrapperArray` is an object that contains an array of [`Wrappers`](../wrapper/
!!!include(docs/api/wrapper-array/at.md)!!!
!!!include(docs/api/wrapper-array/contains.md)!!!
!!!include(docs/api/wrapper-array/destroy.md)!!!
!!!include(docs/api/wrapper-array/exists.md)!!!
!!!include(docs/api/wrapper-array/filter.md)!!!
!!!include(docs/api/wrapper-array/is.md)!!!
!!!include(docs/api/wrapper-array/isEmpty.md)!!!
Expand Down
19 changes: 19 additions & 0 deletions docs/api/wrapper-array/exists.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## exists

Assert `WrapperArray` exists.

Returns false if called on a `WrapperArray` with no `Wrapper` objects, or if
any of them do not exist.

- **Returns:** `{boolean}`

- **Example:**

```js
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
expect(wrapper.findAll('div').exists()).toBe(true)
expect(wrapper.findAll('does-not-exist').exists()).toBe(false)
```
6 changes: 2 additions & 4 deletions docs/api/wrapper/exists.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## exists

Assert `Wrapper` or `WrapperArray` exists.
Assert `Wrapper` exists.

Returns false if called on an empty `Wrapper` or `WrapperArray`.
Returns false if called on a `Wrapper` which does not exist.

- **Returns:** `{boolean}`

Expand All @@ -15,6 +15,4 @@ import Foo from './Foo.vue'
const wrapper = mount(Foo)
expect(wrapper.exists()).toBe(true)
expect(wrapper.find('does-not-exist').exists()).toBe(false)
expect(wrapper.findAll('div').exists()).toBe(true)
expect(wrapper.findAll('does-not-exist').exists()).toBe(false)
```
2 changes: 1 addition & 1 deletion packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class Wrapper implements BaseWrapper {
}

/**
* Utility to check wrapper exists. Returns true as Wrapper always exists
* Utility to check wrapper exists.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appeared to be an outdated comment for the exists method, since it a Wrapper doesn't always exist, since it can return false 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed!

*/
exists(): boolean {
if (this.vm) {
Expand Down