Skip to content

Commit

Permalink
docs: add WrapperArray#exists docs (#1795)
Browse files Browse the repository at this point in the history
  • Loading branch information
markrian authored Feb 22, 2021
1 parent 30e5bc3 commit a956468
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
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.
*/
exists(): boolean {
if (this.vm) {
Expand Down

0 comments on commit a956468

Please sign in to comment.