@@ -324,6 +324,64 @@ describe('Grid factory', function() {
324
324
} ) ;
325
325
} ) ;
326
326
327
+ describe ( 'getting Rows' , function ( ) {
328
+ it ( 'should get Rows' , function ( ) {
329
+ expect ( grid . getRow ( ) ) . toBe ( null ) ;
330
+ expect ( grid . getRows ( grid . rows [ 0 ] . entity ) ) . toBe ( grid . rows [ 0 ] ) ;
331
+ expect ( grid . getRows ( grid . rows [ 0 ] . entity ) , [ grid . rows [ 0 ] ] ) . toBe ( grid . rows [ 0 ] ) ;
332
+ } ) ;
333
+
334
+ it ( 'should get Rows by key' , function ( ) {
335
+ grid . rows [ 0 ] . entity = { str : 'abc' , num : 123 , nll : null , multi : true } ;
336
+ grid . rows [ 1 ] . entity = { multi : true } ;
337
+ grid . rows [ 0 ] . str = 'abc' ;
338
+ grid . rows [ 0 ] . num = 123 ;
339
+ grid . rows [ 0 ] . nll = null ;
340
+ grid . rows [ 0 ] . innerMulti = false ;
341
+ grid . rows [ 1 ] . innerMulti = false ;
342
+
343
+ expect ( grid . getRowsByKey ( ) ) . toBe ( null ) ;
344
+ expect ( grid . getRowsByKey ( true , "test" ) ) . toBe ( null ) ;
345
+ expect ( grid . getRowsByKey ( true , "str" , "abc" ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
346
+ expect ( grid . getRowsByKey ( true , "str" , "def" ) ) . toBe ( null ) ;
347
+ expect ( grid . getRowsByKey ( true , "num" , 123 ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
348
+ expect ( grid . getRowsByKey ( true , "nll" , null ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
349
+ expect ( grid . getRowsByKey ( true , "multi" , true ) . length ) . toBe ( 2 ) ;
350
+
351
+ expect ( grid . getRowsByKey ( false , "test" ) ) . toBe ( null ) ;
352
+ expect ( grid . getRowsByKey ( false , "str" , "abc" ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
353
+ expect ( grid . getRowsByKey ( false , "str" , "def" ) ) . toBe ( null ) ;
354
+ expect ( grid . getRowsByKey ( false , "num" , 123 ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
355
+ expect ( grid . getRowsByKey ( false , "nll" , null ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
356
+ expect ( grid . getRowsByKey ( true , "innerMulti" , false ) . length ) . toBe ( 2 ) ;
357
+ } ) ;
358
+
359
+ it ( 'should find first Row by key' , function ( ) {
360
+ grid . rows [ 0 ] . entity = { str : 'abc' , num : 123 , nll : null , multi : true } ;
361
+ grid . rows [ 1 ] . entity = { multi : true } ;
362
+ grid . rows [ 0 ] . str = 'abc' ;
363
+ grid . rows [ 0 ] . num = 123 ;
364
+ grid . rows [ 0 ] . nll = null ;
365
+ grid . rows [ 0 ] . innerMulti = false ;
366
+ grid . rows [ 1 ] . innerMulti = false ;
367
+
368
+ expect ( grid . findRowByKey ( ) ) . toBe ( null ) ;
369
+ expect ( grid . findRowByKey ( true , "test" ) ) . toBe ( null ) ;
370
+ expect ( grid . findRowByKey ( true , "str" , "abc" ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
371
+ expect ( grid . findRowByKey ( true , "str" , "def" ) ) . toBe ( null ) ;
372
+ expect ( grid . findRowByKey ( true , "num" , 123 ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
373
+ expect ( grid . findRowByKey ( true , "nll" , null ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
374
+ expect ( grid . findRowByKey ( true , "multi" , true ) . length ) . toBe ( 1 ) ;
375
+
376
+ expect ( grid . findRowByKey ( false , "test" ) ) . toBe ( null ) ;
377
+ expect ( grid . findRowByKey ( false , "str" , "abc" ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
378
+ expect ( grid . findRowByKey ( false , "str" , "def" ) ) . toBe ( null ) ;
379
+ expect ( grid . findRowByKey ( false , "num" , 123 ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
380
+ expect ( grid . findRowByKey ( false , "nll" , null ) ) . toBe ( [ grid . rows [ 0 ] ] ) ;
381
+ expect ( grid . findRowByKey ( true , "innerMulti" , false ) . length ) . toBe ( 1 ) ;
382
+ } ) ;
383
+ } )
384
+
327
385
describe ( 'buildColumns' , function ( ) {
328
386
it ( 'guess correct column types when not specified' , function ( ) {
329
387
var dataRow = { str : 'abc' , num : 123 , dat : new Date ( ) , bool : true , obj : { } , nll : null , negNum : - 1 , posNum : + 1 } ;
0 commit comments