@@ -233,20 +233,41 @@ describe('Test sunburst calc:', function() {
233233 expect ( Lib . warn ) . toHaveBeenCalledTimes ( 0 ) ;
234234 } ) ;
235235
236- it ( 'should warn when values under *branchvalues:total* do not add up' , function ( ) {
236+ it ( 'should warn when values under *branchvalues:total* do not add up and not show trace ' , function ( ) {
237237 _calc ( {
238238 labels : [ 'Root' , 'A' , 'B' , 'b' ] ,
239239 parents : [ '' , 'Root' , 'Root' , 'B' ] ,
240240 values : [ 0 , 1 , 2 , 3 ] ,
241241 branchvalues : 'total'
242242 } ) ;
243243
244- expect ( extractPt ( 'value' ) ) . toEqual ( [ 3 , 3 , 1 , 3 ] ) ;
244+ expect ( gd . calcdata [ 0 ] [ 0 ] . hierarchy ) . toBe ( undefined , 'no computed hierarchy' ) ;
245245
246246 expect ( Lib . warn ) . toHaveBeenCalledTimes ( 2 ) ;
247247 expect ( Lib . warn . calls . allArgs ( ) [ 0 ] [ 0 ] ) . toBe ( 'Total value for node Root is smaller than the sum of its children.' ) ;
248248 expect ( Lib . warn . calls . allArgs ( ) [ 1 ] [ 0 ] ) . toBe ( 'Total value for node B is smaller than the sum of its children.' ) ;
249249 } ) ;
250+
251+ it ( 'should warn labels/parents lead to ambiguous hierarchy' , function ( ) {
252+ _calc ( {
253+ labels : [ 'Root' , 'A' , 'A' , 'B' ] ,
254+ parents : [ '' , 'Root' , 'Root' , 'A' ]
255+ } ) ;
256+
257+ expect ( Lib . warn ) . toHaveBeenCalledTimes ( 1 ) ;
258+ expect ( Lib . warn ) . toHaveBeenCalledWith ( 'Failed to build sunburst hierarchy. Error: ambiguous: A' ) ;
259+ } ) ;
260+
261+ it ( 'should warn ids/parents lead to ambiguous hierarchy' , function ( ) {
262+ _calc ( {
263+ labels : [ 'label 1' , 'label 2' , 'label 3' , 'label 4' ] ,
264+ ids : [ 'a' , 'b' , 'b' , 'c' ] ,
265+ parents : [ '' , 'a' , 'a' , 'b' ]
266+ } ) ;
267+
268+ expect ( Lib . warn ) . toHaveBeenCalledTimes ( 1 ) ;
269+ expect ( Lib . warn ) . toHaveBeenCalledWith ( 'Failed to build sunburst hierarchy. Error: ambiguous: b' ) ;
270+ } ) ;
250271} ) ;
251272
252273describe ( 'Test sunburst hover:' , function ( ) {
0 commit comments