@@ -55,10 +55,21 @@ describe('Pie defaults', function() {
5555 expect ( out . visible ) . toBe ( false ) ;
5656 } ) ;
5757
58- it ( 'allows falsy json values to skip but does not allow bad values and zero sum' , function ( ) {
59- var out ;
58+ it ( 'skip negatives and non-JSON values and avoid zero total' , function ( ) {
59+ [
60+ - 1 , '-1' ,
61+ 0 , '0' ,
62+ false , 'false' ,
63+ true , 'true' ,
64+ null , 'null' ,
65+ NaN , 'NaN' ,
66+ - Infinity , '-Infinity' ,
67+ Infinity , 'Infinity' ,
68+ undefined , 'undefined' ,
69+ '' , [ ] , { }
70+ ] . forEach ( function ( e ) {
71+ var out ;
6072
61- [ null , 0 , '' , false ] . forEach ( function ( e ) {
6273 out = _supply ( { type : 'pie' , values : [ 1 , e , 3 ] } ) ;
6374 expect ( out . visible ) . toBe ( true , e ) ;
6475 expect ( out . _length ) . toBe ( 3 , e ) ;
@@ -75,18 +86,12 @@ describe('Pie defaults', function() {
7586 expect ( out . visible ) . toBe ( false , e ) ;
7687 expect ( out . _length ) . toBe ( undefined , e ) ;
7788 } ) ;
89+ } ) ;
7890
79- [ 'not a positive value' , '-1' , - 1 , NaN , - Infinity , undefined ] . forEach ( function ( e ) {
80- out = _supply ( { type : 'pie' , values : [ 0 , e ] } ) ;
81- expect ( out . visible ) . toBe ( false , e ) ;
82- expect ( out . _length ) . toBe ( undefined , e ) ;
83-
84- out = _supply ( { type : 'pie' , values : [ 1 , e ] } ) ;
85- expect ( out . visible ) . toBe ( false , e ) ;
86- expect ( out . _length ) . toBe ( undefined , e ) ;
87- } ) ;
88-
91+ it ( 'convert positive numbers in string format' , function ( ) {
8992 [ '1' , '+1' , '1e1' ] . forEach ( function ( e ) {
93+ var out ;
94+
9095 out = _supply ( { type : 'pie' , values : [ 0 , e ] } ) ;
9196 expect ( out . visible ) . toBe ( true , e ) ;
9297 expect ( out . _length ) . toBe ( 2 , e ) ;
0 commit comments