@@ -51,6 +51,7 @@ describe('reactivity/reactive/Array', () => {
5151 const raw = { }
5252 const arr = reactive ( [ { } , { } ] )
5353 arr . push ( raw )
54+
5455 expect ( arr . indexOf ( raw ) ) . toBe ( 2 )
5556 expect ( arr . indexOf ( raw , 3 ) ) . toBe ( - 1 )
5657 expect ( arr . includes ( raw ) ) . toBe ( true )
@@ -90,24 +91,28 @@ describe('reactivity/reactive/Array', () => {
9091 } )
9192
9293 // only non-existent reactive will try to search by using its raw value
93- describe ( 'Array identity methods have been called times ' , ( ) => {
94+ describe ( 'Array identity methods should not be called more than necessary ' , ( ) => {
9495 const identityMethods = [ 'includes' , 'indexOf' , 'lastIndexOf' ] as const
96+
9597 function instrumentArr ( rawTarget : any [ ] ) {
9698 identityMethods . forEach ( key => {
9799 const spy = vi . fn ( rawTarget [ key ] as any )
98100 rawTarget [ key ] = spy
99101 } )
100102 }
103+
101104 function searchValue ( target : any [ ] , ...args : unknown [ ] ) {
102105 return identityMethods . map ( key => ( target [ key ] as any ) ( ...args ) )
103106 }
107+
104108 function unInstrumentArr ( rawTarget : any [ ] ) {
105109 identityMethods . forEach ( key => {
106110 ; ( rawTarget [ key ] as any ) . mockClear ( )
107111 // relink to prototype method
108112 rawTarget [ key ] = Array . prototype [ key ] as any
109113 } )
110114 }
115+
111116 function expectHaveBeenCalledTimes ( rawTarget : any [ ] , times : number ) {
112117 identityMethods . forEach ( key => {
113118 expect ( rawTarget [ key ] ) . toHaveBeenCalledTimes ( times )
0 commit comments