@@ -233,20 +233,41 @@ describe('Test sunburst calc:', function() {
233
233
expect ( Lib . warn ) . toHaveBeenCalledTimes ( 0 ) ;
234
234
} ) ;
235
235
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 ( ) {
237
237
_calc ( {
238
238
labels : [ 'Root' , 'A' , 'B' , 'b' ] ,
239
239
parents : [ '' , 'Root' , 'Root' , 'B' ] ,
240
240
values : [ 0 , 1 , 2 , 3 ] ,
241
241
branchvalues : 'total'
242
242
} ) ;
243
243
244
- expect ( extractPt ( 'value' ) ) . toEqual ( [ 3 , 3 , 1 , 3 ] ) ;
244
+ expect ( gd . calcdata [ 0 ] [ 0 ] . hierarchy ) . toBe ( undefined , 'no computed hierarchy' ) ;
245
245
246
246
expect ( Lib . warn ) . toHaveBeenCalledTimes ( 2 ) ;
247
247
expect ( Lib . warn . calls . allArgs ( ) [ 0 ] [ 0 ] ) . toBe ( 'Total value for node Root is smaller than the sum of its children.' ) ;
248
248
expect ( Lib . warn . calls . allArgs ( ) [ 1 ] [ 0 ] ) . toBe ( 'Total value for node B is smaller than the sum of its children.' ) ;
249
249
} ) ;
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
+ } ) ;
250
271
} ) ;
251
272
252
273
describe ( 'Test sunburst hover:' , function ( ) {
0 commit comments