@@ -19,19 +19,22 @@ test('Test vtkDataArray instance', (t) => {
1919
2020 t . throws (
2121 ( ) => vtkDataArray . newInstance ( { } ) ,
22- 'Create instance without values '
22+ 'Not allowed to create instance without initialValues '
2323 ) ;
2424
25- t . doesNotThrow ( ( ) => vtkDataArray . newInstance ( { empty : true } ) ) ;
25+ t . doesNotThrow (
26+ ( ) => vtkDataArray . newInstance ( { empty : true } ) ,
27+ 'Allowed to create instance with empty true, no values'
28+ ) ;
2629
2730 t . throws (
2831 ( ) => vtkDataArray . newInstance ( { empty : false } ) ,
29- 'Create instance with empty false, no values'
32+ 'Not allowed to create instance with empty false, no values'
3033 ) ;
3134
3235 t . doesNotThrow (
3336 ( ) => vtkDataArray . newInstance ( { size : 256 } ) ,
34- 'Create instance with only size'
37+ 'Allowed to create instance with only size'
3538 ) ;
3639
3740 const dataArray0 = vtkDataArray . newInstance ( {
@@ -137,7 +140,7 @@ test('Test vtkDataArray setData', (t) => {
137140 values : macro . newTypedArrayFrom ( DefaultDataType , [ 4 , 5 , 6 , 7 ] ) ,
138141 } ,
139142 getDataArrayProperties ( dataArray ) ,
140- 'Change data of existing instance'
143+ 'Change values of existing instance'
141144 ) ;
142145
143146 dataArray . setData ( [ 1 , 2 , 3 , 4 , 5 , 6 ] , 2 ) ;
@@ -176,28 +179,29 @@ test('Test vtkDataArray setData', (t) => {
176179 'Empty an instance (pass [] array)'
177180 ) ;
178181
179- // For both of those cases, check it does not change the DataArray
180- // Not supposed to call setData with typedArray = null
182+ // Fill the DataArray before so that we are sure the size and the numberOfComponents is updated
183+ dataArray . setData ( [ 1 , 2 , 3 ] , 3 ) ;
181184 dataArray . setData ( null ) ;
182185 t . deepEqual (
183186 {
184187 dataType : DefaultDataType ,
185188 size : 0 ,
186189 numberOfComponents : 1 ,
187- values : macro . newTypedArray ( DefaultDataType ) ,
190+ values : null ,
188191 } ,
189192 getDataArrayProperties ( dataArray ) ,
190193 'Call setData with typedArray = null'
191194 ) ;
192195
193- // Not supposed to call setData without parameters
196+ // Not supposed to call setData without parameters : check it does nothing on the DataArray
197+ dataArray . setData ( [ 1 , 2 , 3 ] ) ;
194198 dataArray . setData ( ) ;
195199 t . deepEqual (
196200 {
197201 dataType : DefaultDataType ,
198- size : 0 ,
202+ size : 3 ,
199203 numberOfComponents : 1 ,
200- values : macro . newTypedArray ( DefaultDataType ) ,
204+ values : macro . newTypedArrayFrom ( DefaultDataType , [ 1 , 2 , 3 ] ) ,
201205 } ,
202206 getDataArrayProperties ( dataArray ) ,
203207 'Call setData with typedArray = undefined'
@@ -212,7 +216,7 @@ test('Test vtkDataArray setData', (t) => {
212216 values : macro . newTypedArrayFrom ( 'Uint32Array' , [ 4 , 5 , 6 , 7 ] ) ,
213217 } ,
214218 getDataArrayProperties ( dataArray ) ,
215- 'Change data of existing instance with another type'
219+ 'Change values of existing instance with another type'
216220 ) ;
217221} ) ;
218222
0 commit comments