@@ -614,6 +614,74 @@ describe('filter transforms calc:', function() {
614614 expect ( out [ 0 ] . y ) . toEqual ( [ 2 , 2 , 3 ] ) ;
615615 expect ( out [ 0 ] . ids ) . toEqual ( [ 'n1' , 'p1' , 'p2' ] ) ;
616616 } ) ;
617+
618+ describe ( 'filters should handle array *target* values' , function ( ) {
619+ var _base = Lib . extendDeep ( { } , base ) ;
620+
621+ function _assert ( out , x , y , markerColor ) {
622+ expect ( out [ 0 ] . x ) . toEqual ( x , '- x coords' ) ;
623+ expect ( out [ 0 ] . y ) . toEqual ( y , '- y coords' ) ;
624+ expect ( out [ 0 ] . marker . color ) . toEqual ( markerColor , '- marker.color arrayOk' ) ;
625+ expect ( out [ 0 ] . marker . size ) . toEqual ( 20 , '- marker.size style' ) ;
626+ }
627+
628+ it ( 'with numeric items' , function ( ) {
629+ var out = _transform ( [ Lib . extendDeep ( { } , _base , {
630+ transforms : [ {
631+ target : [ 1 , 1 , 0 , 0 , 1 , 0 , 1 ] ,
632+ operation : '{}' ,
633+ value : 0
634+ } ]
635+ } ) ] ) ;
636+
637+ _assert ( out , [ - 2 , 0 , 2 ] , [ 3 , 1 , 3 ] , [ 0.3 , 0.1 , 0.3 ] ) ;
638+ expect ( out [ 0 ] . transforms [ 0 ] . target ) . toEqual ( [ 0 , 0 , 0 ] ) ;
639+ } ) ;
640+
641+ it ( 'with categorical items' , function ( ) {
642+ var out = _transform ( [ Lib . extendDeep ( { } , _base , {
643+ transforms : [ {
644+ target : [ 'a' , 'a' , 'b' , 'b' , 'a' , 'b' , 'a' ] ,
645+ operation : '{}' ,
646+ value : 'b'
647+ } ]
648+ } ) ] ) ;
649+
650+ _assert ( out , [ - 2 , 0 , 2 ] , [ 3 , 1 , 3 ] , [ 0.3 , 0.1 , 0.3 ] ) ;
651+ expect ( out [ 0 ] . transforms [ 0 ] . target ) . toEqual ( [ 'b' , 'b' , 'b' ] ) ;
652+ } ) ;
653+
654+ it ( 'with dates items' , function ( ) {
655+ var out = _transform ( [ Lib . extendDeep ( { } , _base , {
656+ transforms : [ {
657+ target : [ '2015-07-20' , '2016-08-01' , '2016-09-01' , '2016-10-21' , '2016-12-02' ] ,
658+ operation : '<' ,
659+ value : '2016-01-01'
660+ } ]
661+ } ) ] ) ;
662+
663+ _assert ( out , [ - 2 ] , [ 1 ] , [ 0.1 ] ) ;
664+ expect ( out [ 0 ] . transforms [ 0 ] . target ) . toEqual ( [ '2015-07-20' ] ) ;
665+ } ) ;
666+
667+ it ( 'with multiple transforms (dates) ' , function ( ) {
668+ var out = _transform ( [ Lib . extendDeep ( { } , _base , {
669+ transforms : [ {
670+ target : [ '2015-07-20' , '2016-08-01' , '2016-09-01' , '2016-10-21' , '2016-12-02' ] ,
671+ operation : '>' ,
672+ value : '2016-01-01'
673+ } , {
674+ type : 'filter' ,
675+ target : [ '2015-07-20' , '2016-08-01' , '2016-09-01' , '2016-10-21' , '2016-12-02' ] ,
676+ operation : '<' ,
677+ value : '2016-09-01'
678+ } ]
679+ } ) ] ) ;
680+
681+ _assert ( out , [ - 1 ] , [ 2 ] , [ 0.2 ] ) ;
682+ expect ( out [ 0 ] . transforms [ 0 ] . target ) . toEqual ( [ '2016-08-01' ] ) ;
683+ } ) ;
684+ } ) ;
617685} ) ;
618686
619687describe ( 'filter transforms interactions' , function ( ) {
0 commit comments