@@ -82,11 +82,36 @@ suite.addBatch({
8282 assert . equal ( pack ( ) . radius ( ) , null ) ;
8383 } ,
8484 "radius can be specified using a custom function of value" : function ( pack ) {
85- var p = pack ( ) . radius ( function ( value ) { return Math . sqrt ( value ) * 10 ; } ) ;
85+ var r = function ( value ) { return Math . sqrt ( value ) * 10 ; } ,
86+ p = pack ( ) . radius ( r ) ;
87+ assert . strictEqual ( p . radius ( ) , r ) ;
8688 assert . deepEqual ( p . nodes ( { children : [ { value : 1 } ] } ) . map ( layout ) , [
8789 { value : 1 , depth : 0 , x : 0.5 , y : 0.5 , r : 10 } ,
8890 { value : 1 , depth : 1 , x : 0.5 , y : 0.5 , r : 10 }
8991 ] ) ;
92+ } ,
93+ "radius can be specified as a constant" : function ( pack ) {
94+ var p = pack ( ) . radius ( 5 ) ;
95+ assert . equal ( p . radius ( ) , 5 ) ;
96+ assert . deepEqual ( p . nodes ( { children : [ { value : 1 } ] } ) . map ( layout ) , [
97+ { value : 1 , depth : 0 , x : 0.5 , y : 0.5 , r : 5 } ,
98+ { value : 1 , depth : 1 , x : 0.5 , y : 0.5 , r : 5 }
99+ ] ) ;
100+ } ,
101+ "radius constant value is coerced to a number" : function ( pack ) {
102+ var p = pack ( ) . radius ( "5" ) ;
103+ assert . equal ( p . radius ( ) , 5 ) ;
104+ assert . deepEqual ( p . nodes ( { children : [ { value : 1 } ] } ) . map ( layout ) , [
105+ { value : 1 , depth : 0 , x : 0.5 , y : 0.5 , r : 5 } ,
106+ { value : 1 , depth : 1 , x : 0.5 , y : 0.5 , r : 5 }
107+ ] ) ;
108+ } ,
109+ "radius function value is coerced to a number" : function ( pack ) {
110+ var p = pack ( ) . radius ( function ( ) { return "5" ; } ) ;
111+ assert . deepEqual ( p . nodes ( { children : [ { value : 1 } ] } ) . map ( layout ) , [
112+ { value : 1 , depth : 0 , x : 0.5 , y : 0.5 , r : 5 } ,
113+ { value : 1 , depth : 1 , x : 0.5 , y : 0.5 , r : 5 }
114+ ] ) ;
90115 }
91116 }
92117} ) ;
0 commit comments