@@ -7,13 +7,19 @@ describeWithShallowAndMount('WrapperArray', mountingMethod => {
7
7
const wrapper = mountingMethod ( compiled )
8
8
const wrapperArray = wrapper . findAll ( 'p' )
9
9
expect ( wrapperArray . constructor . name ) . to . equal ( 'WrapperArray' )
10
- if ( wrappers ) {
11
- wrapperArray . wrappers = wrappers
12
- wrapperArray . length = wrappers . length
13
- }
14
- return wrapperArray
10
+ return wrappers ? new wrapperArray . constructor ( wrappers ) : wrapperArray
15
11
}
16
12
13
+ [ 'wrappers' , 'length' ] . forEach ( property => {
14
+ it ( `has the ${ property } property which is read-only` , ( ) => {
15
+ const wrapperArray = getWrapperArray ( )
16
+ const message = `[vue-test-utils]: wrapperArray.${ property } is read-only`
17
+ expect ( ( ) => { wrapperArray [ property ] = 'foo' } )
18
+ . to . throw ( )
19
+ . with . property ( 'message' , message )
20
+ } )
21
+ } )
22
+
17
23
it ( 'returns class with length equal to length of wrappers passed in constructor' , ( ) => {
18
24
const wrapperArray = getWrapperArray ( )
19
25
expect ( wrapperArray . length ) . to . equal ( 3 )
@@ -67,8 +73,7 @@ describeWithShallowAndMount('WrapperArray', mountingMethod => {
67
73
if ( method === 'at' ) {
68
74
return
69
75
}
70
- const wrapperArray = getWrapperArray ( )
71
- wrapperArray . wrappers = [ ]
76
+ const wrapperArray = getWrapperArray ( [ ] )
72
77
const message = `[vue-test-utils]: ${ method } cannot be called on 0 items`
73
78
expect ( ( ) => wrapperArray [ method ] ( ) )
74
79
. to . throw ( )
@@ -99,8 +104,7 @@ describeWithShallowAndMount('WrapperArray', mountingMethod => {
99
104
) {
100
105
return
101
106
}
102
- const wrapperArray = getWrapperArray ( )
103
- wrapperArray . wrappers = [ 1 , 2 , 3 ]
107
+ const wrapperArray = getWrapperArray ( [ 1 , 2 , 3 ] )
104
108
const message = `[vue-test-utils]: ${ method } must be called on a single wrapper, use at(i) to access a wrapper`
105
109
expect ( ( ) => wrapperArray [ method ] ( ) )
106
110
. to . throw ( )
0 commit comments