File tree 16 files changed +80
-108
lines changed
16 files changed +80
-108
lines changed Original file line number Diff line number Diff line change 35
35
* [ update] ( api/wrapper-array/update.md )
36
36
* [ setData] ( api/wrapper-array/setData.md )
37
37
* [ setProps] ( api/wrapper-array/setProps.md )
38
- * [ text] ( api/wrapper-array/trigger .md )
38
+ * [ text] ( api/wrapper-array/text .md )
39
39
* [ trigger] ( api/wrapper-array/trigger.md )
40
40
* [ selectors] ( api/selectors.md )
Original file line number Diff line number Diff line change 2
2
3
3
A ` WrapperArray ` is an object that contains an array of [ Wrappers] ( /api/wrapper/README.md ) , and methods to test the ` Wrappers ` .
4
4
5
- ## Properties
5
+ - ** Properties: **
6
6
7
7
` length ` ` number ` : the number of ` Wrappers ` contained in the ` WrapperArray `
8
8
9
- ## Methods
9
+ - ** Methods: **
10
10
11
11
There is a detailed list of methods in the WrapperArray section of the docs.
Original file line number Diff line number Diff line change 1
1
# at(index)
2
2
3
- Returns Wrapper at ` index `
3
+ - ** Arguments:**
4
+ - ` {number} index `
4
5
5
- ### Arguments
6
+ - ** Returns: ** ` {Wrapper} `
6
7
7
- ` index ` ( ` number ` ): index of Wrapper to return.
8
+ - ** Usage: **
8
9
9
- ### Returns
10
-
11
- (` Wrapper ` ): returns ` Wrapper ` at ` index ` passed. Uses zero based numbering (i.e. first item is at index 0)
12
-
13
- ### Example
10
+ Returns ` Wrapper ` at ` index ` passed. Uses zero based numbering (i.e. first item is at index 0).
14
11
15
12
``` js
16
13
import { shallow } from ' vue-test-utils'
Original file line number Diff line number Diff line change 1
1
# contains(selector)
2
2
3
- Returns true if every wrapper in array contains selector. Use any valid [ selector] ( /api/selectors.md ) .
3
+ - ** Arguments:**
4
+ - ` {string|Component} selector `
4
5
5
- ### Arguments
6
+ - ** Returns: ** ` {boolean} `
6
7
7
- ` selector ` ( ` String ` | ` Component ` ): a CSS selector ('#id', '.class-name', 'tag') or a Vue component. See [ selectors ] ( /api/selectors.md ) .
8
+ - ** Usage: **
8
9
9
- ### Returns
10
+ Assert every wrapper in ` WrapperArray ` contains selector.
10
11
11
- (` Boolean ` ): returns ` true ` if every wrapper in wrapper array contains selector.
12
-
13
- ### Example
14
-
15
- ``` js
16
- import { shallow } from ' vue-test-utils'
17
- import { expect } from ' chai'
18
- import Foo from ' ./Foo.vue'
19
-
20
- const wrapper = shallow (Foo)
21
- const divArray = wrapper .findAll (' div' )
22
- expect (divArray .contains (' p' )).to .equal (true )
23
- ```
12
+ Use any valid [ selector] ( /api/selectors.md ) .
24
13
25
14
``` js
26
15
import { shallow } from ' vue-test-utils'
@@ -30,5 +19,6 @@ import Bar from './Bar.vue'
30
19
31
20
const wrapper = shallow (Foo)
32
21
const divArray = wrapper .findAll (' div' )
22
+ expect (divArray .contains (' p' )).to .equal (true )
33
23
expect (divArray .contains (Bar)).to .equal (true )
34
24
```
Original file line number Diff line number Diff line change 1
1
# hasAttribute(attribute, value)
2
2
3
- Check if every wrapper vnode in wrapper array has attribute matching value
3
+ - ** Arguments:**
4
+ - ` {string} attribute `
5
+ - ` {string} value `
4
6
5
- ### Arguments
7
+ - ** Returns: ** ` {boolean} `
6
8
7
- ` attribute ` ( ` String ` ): attribute name to assert value of.
9
+ - ** Usage: **
8
10
9
- ` value ` (` String ` ): the value attribute should hold.
10
-
11
- ### Returns
12
-
13
- (` Boolean ` ): ` true ` if every wrapper vnode contains attribute with matching value, ` false ` otherwise.
14
-
15
- ## Example
11
+ Assert every ` Wrapper ` in ` WrapperArray ` DOM node has ` attribute ` matching ` value ` .
16
12
17
13
``` js
18
14
import { mount } from ' vue-test-utils'
Original file line number Diff line number Diff line change 1
1
# hasClass(className)
2
2
3
- Check if every wrapper vnode in wrapper array has a class name containing ` className ` . Returns a boolean.
3
+ - ** Arguments:**
4
+ - ` {string} className `
4
5
5
- ### Arguments
6
+ - ** Returns: ** ` {boolean} `
6
7
7
- ` className ` ( ` String ` ): class name to assert vnode contains.
8
+ - ** Usage: **
8
9
9
- ### Returns
10
-
11
- (` Boolean ` ): ` true ` if every wrapper vnode contains class. ` false ` otherwise.
12
-
13
- ## Example
10
+ Assert every ` Wrapper ` in ` WrapperArray ` DOM node has class containing ` className ` .
14
11
15
12
``` js
16
13
import { mount } from ' vue-test-utils'
Original file line number Diff line number Diff line change @@ -4,17 +4,19 @@ Check if every wrapper vm in wrapper array has prop matching value
4
4
5
5
Can only be called on a Vue instance.
6
6
7
- ### Arguments
7
+ # hasProp(prop, value)
8
8
9
- ` prop ` (` String ` ): prop name to assert value of.
9
+ - ** Arguments:**
10
+ - ` {string} prop `
11
+ - ` {any} value `
10
12
11
- ` value ` ( ` String ` ): the value prop should hold.
13
+ - ** Returns: ** ` {boolean} `
12
14
13
- ### Returns
15
+ - ** Usage: **
14
16
15
- ( ` Boolean ` ): ` true ` if instance has prop. ` false ` if not .
17
+ Assert every ` Wrapper ` in ` WrapperArray ` ` vm ` has ` prop ` matching ` value ` .
16
18
17
- ## Example
19
+ ** Note the Wrapper must contain a Vue instance. **
18
20
19
21
``` js
20
22
import { mount } from ' vue-test-utils'
Original file line number Diff line number Diff line change 1
1
# hasStyle(style, value)
2
2
3
- Check if every wrapper vnode in wrapper array has a ` style ` matching ` value ` . Returns a boolean.
3
+ - ** Arguments:**
4
+ - ` {string} style `
5
+ - ` {string} value `
4
6
5
- ### Arguments
7
+ - ** Returns: ** ` {boolean} `
6
8
7
- ` style ` (` String ` ): style name to assert value of.
8
- ` value ` (` String ` ): the value style property should hold.
9
+ - ** Usage:**
9
10
10
- ### Returns
11
+ Assert every ` Wrapper ` in ` WrapperArray ` DOM node has style matching value.
11
12
12
- (` Boolean ` ): ` true ` if every wrapper vnode contains class. ` false ` otherwise.
13
- ` false ` otherwise.
13
+ Returns ` true ` if ` Wrapper ` DOM node has ` style ` matching ` string ` .
14
+
15
+ ** Note will only detect inline styles when running in ` jsdom ` .**
14
16
15
- ## Example
16
17
``` js
17
18
import { mount } from ' vue-test-utils'
18
19
import { expect } from ' chai'
@@ -22,7 +23,3 @@ const wrapper = mount(Foo)
22
23
const divArray = wrapper .findAll (' div' )
23
24
expect (divArray .hasStyle (' color' , ' red' )).to .equal (true )
24
25
```
25
-
26
- ### Note
27
-
28
- Only checks inline styles when running in ` jsdom ` .
Original file line number Diff line number Diff line change 1
1
# is(selector)
2
2
3
- Returns true if every wrapper in wrapper array matches selector. Use any valid [ selector] ( /api/selectors.md ) .
3
+ - ** Arguments:**
4
+ - ` {string|Component} selector `
4
5
5
- ### Arguments
6
+ - ** Returns: ** ` {boolean} `
6
7
7
- ` selector ` ( ` String ` | ` Component ` ): a CSS selector ('#id', '.class-name', 'tag') or a Vue component. See [ selectors ] ( /api/selectors.md ) .
8
+ - ** Usage: **
8
9
9
- ### Returns
10
-
11
- (` Boolean ` ): returns true if every wrapper in wrapper array matches selector.
12
-
13
- ### Example
10
+ Assert every ` Wrapper ` in ` WrapperArray ` DOM node or ` vm ` matches [ selector] ( /api/selectors.md ) .
14
11
15
12
``` js
16
13
import { mount } from ' vue-test-utils'
@@ -20,4 +17,4 @@ import Foo from './Foo.vue'
20
17
const wrapper = mount (Foo)
21
18
const divArray = wrapper .find (' div' )
22
19
expect (divArray .is (' div' )).to .equal (true )
23
- ```
20
+ ```
Original file line number Diff line number Diff line change 1
1
# isEmpty()
2
2
3
- Check if every wrapper in wrapper array contains child nodes. Returns a boolean.
3
+ - ** Returns: ** ` { boolean} `
4
4
5
- ### Returns
5
+ - ** Usage: **
6
6
7
- (` Boolean ` ): true if every wrapper in wrapper array does not contain any child nodes. False if it does.
8
-
9
- ## Example
7
+ Assert every ` Wrapper ` in ` WrapperArray ` does not contain child node.
10
8
11
9
``` js
12
10
import { mount } from ' vue-test-utils'
@@ -16,4 +14,4 @@ import Foo from './Foo.vue'
16
14
const wrapper = mount (Foo)
17
15
const divArray = wrapper .findAll (' div' )
18
16
expect (divArray .isEmpty ()).to .equal (true )
19
- ```
17
+ ```
Original file line number Diff line number Diff line change 1
1
# isVueInstance()
2
2
3
- Check if every wrapper in wrapper array is vue instance. Returns a boolean.
3
+ - ** Returns: ** ` { boolean} `
4
4
5
- ### Returns
5
+ - ** Usage: **
6
6
7
- (` Boolean ` ): true if node does is vue instance. False if not.
8
-
9
- ## Example
7
+ Assert every ` Wrapper ` in ` WrapperArray ` is Vue instance.
10
8
11
9
``` js
12
10
import { mount } from ' vue-test-utils'
@@ -17,4 +15,4 @@ import Bar from './Bar.vue'
17
15
const wrapper = mount (Foo)
18
16
const barArray = wrapper .findAll (Bar)
19
17
expect (barArray .isVueInstance ()).to .equal (true )
20
- ```
18
+ ```
Original file line number Diff line number Diff line change 1
1
# setData(data)
2
2
3
- Sets Vue instance data and forces update of every wrapper in wrapper array.
3
+ - ** Arguments:**
4
+ - ` {Object} data `
4
5
5
- Can only be called on a wrapper array of Vue component wrappers.
6
+ - ** Usage: **
6
7
7
- ### Arguments
8
+ Sets ` Wrapper ` ` vm ` data and forces update on each ` Wrapper ` in ` WrapperArray ` .
8
9
9
- data (` Object ` ): Data properties and corresponding value to set
10
-
11
- ### Example
10
+ ** Note every ` Wrapper ` must contain a Vue instance.**
12
11
13
12
``` js
14
13
import { mount } from ' vue-test-utils'
@@ -20,4 +19,4 @@ const wrapper = mount(Foo)
20
19
const barArray = wrapper .findAll (Bar)
21
20
barArray .setData ({ foo: ' bar' })
22
21
expect (barArray .at (0 ).vm .foo ).to .equal (' bar' )
23
- ```
22
+ ```
Original file line number Diff line number Diff line change 1
- # setProps(data )
1
+ # setProps(props )
2
2
3
- Sets Vue instance props and forces update of every wrapper in wrapper array.
3
+ - ** Arguments:**
4
+ - ` {Object} props `
4
5
5
- Can only be called on a wrapper array of Vue component wrappers.
6
+ - ** Usage: **
6
7
7
- ### Arguments
8
+ Sets ` Wrapper ` ` vm ` props and forces update on each ` Wrapper ` in ` WrapperArray ` .
8
9
9
- props (` Object ` ): Props properties and corresponding value to set
10
-
11
- ### Example
10
+ ** Note every ` Wrapper ` must contain a Vue instance.**
12
11
13
12
``` js
14
13
import { mount } from ' vue-test-utils'
@@ -20,5 +19,4 @@ const wrapper = mount(Foo)
20
19
const barArray = wrapper .findAll (Bar)
21
20
barArray .setProps ({ foo: ' bar' })
22
21
expect (barArray .at (0 ).vm .foo ).to .equal (' bar' )
23
- ```
24
-
22
+ ```
Original file line number Diff line number Diff line change 1
1
# trigger(eventName)
2
2
3
- Triggers an event on each wrapper in the wrapper array
3
+ - ** Arguments:**
4
+ - `{string} eventName
4
5
5
- ### Arguments
6
+ - ** Usage: **
6
7
7
- event ( ` String ` ): type of event (e.g. click) .
8
+ Triggers an event on every ` Wrapper ` in the ` WrapperArray ` DOM node .
8
9
9
- ## Example
10
+ ** Note every ` Wrapper ` must contain a Vue instance. **
10
11
11
12
``` js
12
13
import { mount } from ' vue-test-utils'
@@ -22,4 +23,4 @@ const wrapper = mount(Foo, {
22
23
const divArray = wrapper .findAll (' div' )
23
24
divArray .trigger (' click' )
24
25
expect (clickHandler .called ).to .equal (true )
25
- ```
26
+ ```
Original file line number Diff line number Diff line change 1
1
# update()
2
2
3
- Force root Vue component to re-render.
3
+ - ** Usage:**
4
+
5
+ Force root Vue component of each ` Wrapper ` in ` WrapperArray ` to re-render.
4
6
5
7
If called on a Vue component wrapper array, it will force each Vue component to re-render.
6
8
Original file line number Diff line number Diff line change 4
4
5
5
- ** Usage:**
6
6
7
- Assert ` Wrapper ` contains child node.
7
+ Assert ` Wrapper ` does not contain child node.
8
8
9
9
``` js
10
10
import { mount } from ' vue-test-utils'
You can’t perform that action at this time.
0 commit comments