@@ -885,6 +885,43 @@ describe('Test lib.js:', function() {
885
885
expect ( coerce ( { x : [ [ ] , [ 0 ] , [ - 1 , 2 ] , [ 5 , 'a' , 4 , 6.6 ] ] } , { } , attrs , 'x' ) )
886
886
. toEqual ( [ [ ] , [ 0 ] , [ 1 , 2 ] , [ 5 , 1 , 4 , 1 ] ] ) ;
887
887
} ) ;
888
+
889
+ it ( 'supports dimensions=\'1-2\' with 1D items array' , function ( ) {
890
+ var attrs = {
891
+ x : {
892
+ valType : 'info_array' ,
893
+ freeLength : true , // in this case only the outer length of 2D is free
894
+ dimensions : '1-2' ,
895
+ items : [
896
+ { valType : 'integer' , min : 0 , max : 5 , dflt : 1 } ,
897
+ { valType : 'integer' , min : 10 , max : 15 , dflt : 11 }
898
+ ]
899
+ }
900
+ } ;
901
+ expect ( coerce ( { } , { } , attrs , 'x' ) ) . toBeUndefined ( ) ;
902
+ expect ( coerce ( { x : [ ] } , { } , attrs , 'x' ) ) . toEqual ( [ 1 , 11 ] ) ;
903
+ expect ( coerce ( { x : [ 4 , 4 , 4 ] } , { } , attrs , 'x' ) ) . toEqual ( [ 4 , 11 ] ) ;
904
+ expect ( coerce ( { x : [ [ ] ] } , { } , attrs , 'x' ) ) . toEqual ( [ [ 1 , 11 ] ] ) ;
905
+ expect ( coerce ( { x : [ [ 12 , 12 , 12 ] ] } , { } , attrs , 'x' ) ) . toEqual ( [ [ 1 , 12 ] ] ) ;
906
+ expect ( coerce ( { x : [ [ ] , 4 , true ] } , { } , attrs , 'x' ) ) . toEqual ( [ [ 1 , 11 ] , [ 1 , 11 ] , [ 1 , 11 ] ] ) ;
907
+ } ) ;
908
+
909
+ it ( 'supports dimensions=\'1-2\' with single item' , function ( ) {
910
+ var attrs = {
911
+ x : {
912
+ valType : 'info_array' ,
913
+ freeLength : true ,
914
+ dimensions : '1-2' ,
915
+ items : { valType : 'integer' , min : 0 , max : 5 , dflt : 1 }
916
+ }
917
+ } ;
918
+ expect ( coerce ( { } , { } , attrs , 'x' ) ) . toBeUndefined ( ) ;
919
+ expect ( coerce ( { x : [ ] } , { } , attrs , 'x' ) ) . toEqual ( [ ] ) ;
920
+ expect ( coerce ( { x : [ - 3 , 3 , 6 , 'a' ] } , { } , attrs , 'x' ) ) . toEqual ( [ 1 , 3 , 1 , 1 ] ) ;
921
+ expect ( coerce ( { x : [ [ ] ] } , { } , attrs , 'x' ) ) . toEqual ( [ [ ] ] ) ;
922
+ expect ( coerce ( { x : [ [ - 1 , 0 , 10 ] ] } , { } , attrs , 'x' ) ) . toEqual ( [ [ 1 , 0 , 1 ] ] ) ;
923
+ expect ( coerce ( { x : [ [ ] , 4 , [ 3 ] , [ - 1 , 10 ] ] } , { } , attrs , 'x' ) ) . toEqual ( [ [ ] , [ ] , [ 3 ] , [ 1 , 1 ] ] ) ;
924
+ } ) ;
888
925
} ) ;
889
926
890
927
describe ( 'subplotid valtype' , function ( ) {
0 commit comments