@@ -231,30 +231,19 @@ describe('sankey tests', function() {
231
231
232
232
var base = { type : 'sankey' } ;
233
233
234
- it ( 'circularity is detected' , function ( ) {
234
+ describe ( 'remove nodes if encountering circularity' , function ( ) {
235
+ var errors ;
235
236
236
- var errors = [ ] ;
237
- spyOn ( Lib , 'error' ) . and . callFake ( function ( msg ) {
238
- errors . push ( msg ) ;
237
+ beforeEach ( function ( ) {
238
+ errors = [ ] ;
239
+ spyOn ( Lib , 'error' ) . and . callFake ( function ( msg ) {
240
+ errors . push ( msg ) ;
241
+ } ) ;
239
242
} ) ;
240
243
241
- _calc ( Lib . extendDeep ( { } , base , {
242
- node : {
243
- label : [ 'a' , 'b' , 'c' ]
244
- } ,
245
- link : {
246
- value : [ 1 , 1 , 1 ] ,
247
- source : [ 0 , 1 , 2 ] ,
248
- target : [ 1 , 2 , 0 ]
249
- }
250
- } ) ) ;
251
-
252
- expect ( errors . length ) . toEqual ( 1 ) ;
253
- } ) ;
254
-
255
- describe ( 'remove nodes if encountering circularity' , function ( ) {
256
-
257
244
it ( 'removing a single self-pointing node' , function ( ) {
245
+ expect ( errors . length ) . toBe ( 0 ) ;
246
+
258
247
var fullTrace = _calc ( Lib . extendDeep ( { } , base , {
259
248
node : {
260
249
label : [ 'a' ]
@@ -270,10 +259,12 @@ describe('sankey tests', function() {
270
259
expect ( fullTrace . link . value ) . toEqual ( [ ] , 'link value(s) removed' ) ;
271
260
expect ( fullTrace . link . source ) . toEqual ( [ ] , 'link source(s) removed' ) ;
272
261
expect ( fullTrace . link . target ) . toEqual ( [ ] , 'link target(s) removed' ) ;
273
-
262
+ expect ( errors . length ) . toBe ( 1 ) ;
274
263
} ) ;
275
264
276
265
it ( 'removing everything if detecting a circle' , function ( ) {
266
+ expect ( errors . length ) . toBe ( 0 ) ;
267
+
277
268
var fullTrace = _calc ( Lib . extendDeep ( { } , base , {
278
269
node : {
279
270
label : [ 'a' , 'b' , 'c' , 'd' , 'e' ]
@@ -289,7 +280,7 @@ describe('sankey tests', function() {
289
280
expect ( fullTrace . link . value ) . toEqual ( [ ] , 'link value(s) removed' ) ;
290
281
expect ( fullTrace . link . source ) . toEqual ( [ ] , 'link source(s) removed' ) ;
291
282
expect ( fullTrace . link . target ) . toEqual ( [ ] , 'link target(s) removed' ) ;
292
-
283
+ expect ( errors . length ) . toBe ( 1 ) ;
293
284
} ) ;
294
285
} ) ;
295
286
} ) ;
@@ -390,15 +381,15 @@ describe('sankey tests', function() {
390
381
_hover ( 404 , 302 ) ;
391
382
392
383
assertLabel (
393
- [ 'Solid' , 'Incoming flow count: 4' , 'Outgoing flow count: 3' , '447TWh' ] ,
384
+ [ 'Solid' , 'incoming flow count: 4' , 'outgoing flow count: 3' , '447TWh' ] ,
394
385
[ 'rgb(148, 103, 189)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
395
386
) ;
396
387
} )
397
388
. then ( function ( ) {
398
389
_hover ( 450 , 300 ) ;
399
390
400
391
assertLabel (
401
- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
392
+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
402
393
[ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
403
394
) ;
404
395
@@ -408,15 +399,15 @@ describe('sankey tests', function() {
408
399
_hover ( 404 , 302 ) ;
409
400
410
401
assertLabel (
411
- [ 'Solid' , 'Incoming flow count: 4' , 'Outgoing flow count: 3' , '447TWh' ] ,
402
+ [ 'Solid' , 'incoming flow count: 4' , 'outgoing flow count: 3' , '447TWh' ] ,
412
403
[ 'rgb(148, 103, 189)' , 'rgb(255, 255, 255)' , 13 , 'Roboto' , 'rgb(255, 255, 255)' ]
413
404
) ;
414
405
} )
415
406
. then ( function ( ) {
416
407
_hover ( 450 , 300 ) ;
417
408
418
409
assertLabel (
419
- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
410
+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
420
411
[ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Roboto' , 'rgb(255, 255, 255)' ]
421
412
) ;
422
413
@@ -431,15 +422,15 @@ describe('sankey tests', function() {
431
422
_hover ( 404 , 302 ) ;
432
423
433
424
assertLabel (
434
- [ 'Solid' , 'Incoming flow count: 4' , 'Outgoing flow count: 3' , '447TWh' ] ,
425
+ [ 'Solid' , 'incoming flow count: 4' , 'outgoing flow count: 3' , '447TWh' ] ,
435
426
[ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' , 20 , 'Roboto' , 'rgb(0, 0, 0)' ]
436
427
) ;
437
428
} )
438
429
. then ( function ( ) {
439
430
_hover ( 450 , 300 ) ;
440
431
441
432
assertLabel (
442
- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
433
+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
443
434
[ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' , 20 , 'Roboto' , 'rgb(0, 0, 0)' ]
444
435
) ;
445
436
} )
@@ -463,7 +454,7 @@ describe('sankey tests', function() {
463
454
_hover ( 450 , 300 ) ;
464
455
465
456
assertLabel (
466
- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
457
+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
467
458
[ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
468
459
) ;
469
460
} )
0 commit comments