@@ -16,11 +16,11 @@ describe('PropertyRangeDocument', () => {
16
16
return /** @type PropertyRangeDocument */ ( elm ) ;
17
17
}
18
18
19
- function findTypePropertyRange ( element , type , index = 0 ) {
19
+ function findTypePropertyRange ( element , type , index = 0 , propIndex = 0 ) {
20
20
type = element . _resolve ( type ) ;
21
21
const props = element . _computeObjectProperties ( type ) ;
22
22
const key = element . _getAmfKey ( element . ns . aml . vocabularies . shapes . range ) ;
23
- return element . _ensureArray ( props [ 0 ] [ key ] ) [ index ] ;
23
+ return element . _ensureArray ( props [ propIndex ] [ key ] ) [ index ] ;
24
24
}
25
25
26
26
async function getTypePropertyRange (
@@ -252,6 +252,58 @@ describe('PropertyRangeDocument', () => {
252
252
} ) ;
253
253
} ) ;
254
254
255
+ describe ( 'Array data rendering' , ( ) => {
256
+ [
257
+ [ 'Regular model' , false ] ,
258
+ [ 'Compact model' , true ] ,
259
+ ] . forEach ( ( item ) => {
260
+ describe ( String ( item [ 0 ] ) , ( ) => {
261
+ let element ;
262
+ let amf ;
263
+ let type ;
264
+
265
+ before ( async ( ) => {
266
+ const data = await AmfLoader . loadType ( 'testType' , item [ 1 ] , 'W-11858334' ) ;
267
+ amf = data [ 0 ] ;
268
+ type = data [ 1 ] ;
269
+ } ) ;
270
+
271
+ beforeEach ( async ( ) => {
272
+ element = await basicFixture ( ) ;
273
+ element . amf = amf ;
274
+ element . range = findTypePropertyRange ( element , type , 0 , 1 ) ;
275
+ await aTimeout ( 0 ) ;
276
+ } ) ;
277
+
278
+ it ( 'Renders array minimum count' , async ( ) => {
279
+ const properties = element . shadowRoot . querySelectorAll ( '.property-attribute' ) ;
280
+ assert . lengthOf ( properties , 2 ) ;
281
+
282
+ const minProperty = properties [ 0 ]
283
+ const label = minProperty . querySelector ( '.attribute-label' ) ;
284
+ assert . equal ( label . innerText , 'Minimum array length:' ) ;
285
+
286
+ const value = minProperty . querySelector ( '.attribute-value' ) ;
287
+ assert . equal ( value . title , 'Minimum amount of items in array' ) ;
288
+ assert . equal ( value . innerText . trim ( ) . toLowerCase ( ) , '3' ) ;
289
+ } ) ;
290
+
291
+ it ( 'Renders array maximum count' , async ( ) => {
292
+ const properties = element . shadowRoot . querySelectorAll ( '.property-attribute' ) ;
293
+ assert . lengthOf ( properties , 2 ) ;
294
+
295
+ const maxProperty = properties [ 1 ]
296
+ const label = maxProperty . querySelector ( '.attribute-label' ) ;
297
+ assert . equal ( label . innerText , 'Maximum array length:' ) ;
298
+
299
+ const value = maxProperty . querySelector ( '.attribute-value' ) ;
300
+ assert . equal ( value . title , 'Maximum amount of items in array' ) ;
301
+ assert . equal ( value . innerText . trim ( ) . toLowerCase ( ) , '10' ) ;
302
+ } ) ;
303
+ } ) ;
304
+ } ) ;
305
+ } ) ;
306
+
255
307
describe ( 'a11y' , ( ) => {
256
308
let element ;
257
309
0 commit comments