@@ -7,13 +7,19 @@ describeWithShallowAndMount('WrapperArray', mountingMethod => {
77 const wrapper = mountingMethod ( compiled )
88 const wrapperArray = wrapper . findAll ( 'p' )
99 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
1511 }
1612
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+
1723 it ( 'returns class with length equal to length of wrappers passed in constructor' , ( ) => {
1824 const wrapperArray = getWrapperArray ( )
1925 expect ( wrapperArray . length ) . to . equal ( 3 )
@@ -67,8 +73,7 @@ describeWithShallowAndMount('WrapperArray', mountingMethod => {
6773 if ( method === 'at' ) {
6874 return
6975 }
70- const wrapperArray = getWrapperArray ( )
71- wrapperArray . wrappers = [ ]
76+ const wrapperArray = getWrapperArray ( [ ] )
7277 const message = `[vue-test-utils]: ${ method } cannot be called on 0 items`
7378 expect ( ( ) => wrapperArray [ method ] ( ) )
7479 . to . throw ( )
@@ -99,8 +104,7 @@ describeWithShallowAndMount('WrapperArray', mountingMethod => {
99104 ) {
100105 return
101106 }
102- const wrapperArray = getWrapperArray ( )
103- wrapperArray . wrappers = [ 1 , 2 , 3 ]
107+ const wrapperArray = getWrapperArray ( [ 1 , 2 , 3 ] )
104108 const message = `[vue-test-utils]: ${ method } must be called on a single wrapper, use at(i) to access a wrapper`
105109 expect ( ( ) => wrapperArray [ method ] ( ) )
106110 . to . throw ( )
0 commit comments