@@ -71,6 +71,49 @@ describe('Funnelarea defaults', function() {
7171 expect ( out . visible ) . toBe ( false ) ;
7272 } ) ;
7373
74+ it ( 'skip negatives and non-JSON values and avoid zero total' , function ( ) {
75+ [
76+ - 1 , '-1' ,
77+ 0 , '0' ,
78+ false , 'false' ,
79+ true , 'true' ,
80+ null , 'null' ,
81+ NaN , 'NaN' ,
82+ - Infinity , '-Infinity' ,
83+ Infinity , 'Infinity' ,
84+ undefined , 'undefined' ,
85+ '' , [ ] , { }
86+ ] . forEach ( function ( e ) {
87+ var out ;
88+
89+ out = _supply ( { type : 'pie' , values : [ 1 , e , 3 ] } ) ;
90+ expect ( out . visible ) . toBe ( true , e ) ;
91+ expect ( out . _length ) . toBe ( 3 , e ) ;
92+
93+ out = _supply ( { type : 'pie' , values : [ 1 , e ] } ) ;
94+ expect ( out . visible ) . toBe ( true , e ) ;
95+ expect ( out . _length ) . toBe ( 2 , e ) ;
96+
97+ out = _supply ( { type : 'pie' , values : [ 0 , e ] } ) ;
98+ expect ( out . visible ) . toBe ( false , e ) ;
99+ expect ( out . _length ) . toBe ( undefined , e ) ;
100+
101+ out = _supply ( { type : 'pie' , values : [ e ] } ) ;
102+ expect ( out . visible ) . toBe ( false , e ) ;
103+ expect ( out . _length ) . toBe ( undefined , e ) ;
104+ } ) ;
105+ } ) ;
106+
107+ it ( 'convert positive numbers in string format' , function ( ) {
108+ [ '1' , '+1' , '1e1' ] . forEach ( function ( e ) {
109+ var out ;
110+
111+ out = _supply ( { type : 'pie' , values : [ 0 , e ] } ) ;
112+ expect ( out . visible ) . toBe ( true , e ) ;
113+ expect ( out . _length ) . toBe ( 2 , e ) ;
114+ } ) ;
115+ } ) ;
116+
74117 it ( 'is marked invisible if either labels or values is empty' , function ( ) {
75118 var out = _supply ( { type : 'funnelarea' , labels : [ ] , values : [ 1 , 2 ] } ) ;
76119 expect ( out . visible ) . toBe ( false ) ;
0 commit comments