@@ -231,30 +231,19 @@ describe('sankey tests', function() {
231231
232232 var base = { type : 'sankey' } ;
233233
234- it ( 'circularity is detected' , function ( ) {
234+ describe ( 'remove nodes if encountering circularity' , function ( ) {
235+ var errors ;
235236
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+ } ) ;
239242 } ) ;
240243
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-
257244 it ( 'removing a single self-pointing node' , function ( ) {
245+ expect ( errors . length ) . toBe ( 0 ) ;
246+
258247 var fullTrace = _calc ( Lib . extendDeep ( { } , base , {
259248 node : {
260249 label : [ 'a' ]
@@ -270,10 +259,12 @@ describe('sankey tests', function() {
270259 expect ( fullTrace . link . value ) . toEqual ( [ ] , 'link value(s) removed' ) ;
271260 expect ( fullTrace . link . source ) . toEqual ( [ ] , 'link source(s) removed' ) ;
272261 expect ( fullTrace . link . target ) . toEqual ( [ ] , 'link target(s) removed' ) ;
273-
262+ expect ( errors . length ) . toBe ( 1 ) ;
274263 } ) ;
275264
276265 it ( 'removing everything if detecting a circle' , function ( ) {
266+ expect ( errors . length ) . toBe ( 0 ) ;
267+
277268 var fullTrace = _calc ( Lib . extendDeep ( { } , base , {
278269 node : {
279270 label : [ 'a' , 'b' , 'c' , 'd' , 'e' ]
@@ -289,7 +280,7 @@ describe('sankey tests', function() {
289280 expect ( fullTrace . link . value ) . toEqual ( [ ] , 'link value(s) removed' ) ;
290281 expect ( fullTrace . link . source ) . toEqual ( [ ] , 'link source(s) removed' ) ;
291282 expect ( fullTrace . link . target ) . toEqual ( [ ] , 'link target(s) removed' ) ;
292-
283+ expect ( errors . length ) . toBe ( 1 ) ;
293284 } ) ;
294285 } ) ;
295286 } ) ;
@@ -390,15 +381,15 @@ describe('sankey tests', function() {
390381 _hover ( 404 , 302 ) ;
391382
392383 assertLabel (
393- [ 'Solid' , 'Incoming flow count: 4' , 'Outgoing flow count: 3' , '447TWh' ] ,
384+ [ 'Solid' , 'incoming flow count: 4' , 'outgoing flow count: 3' , '447TWh' ] ,
394385 [ 'rgb(148, 103, 189)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
395386 ) ;
396387 } )
397388 . then ( function ( ) {
398389 _hover ( 450 , 300 ) ;
399390
400391 assertLabel (
401- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
392+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
402393 [ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
403394 ) ;
404395
@@ -408,15 +399,15 @@ describe('sankey tests', function() {
408399 _hover ( 404 , 302 ) ;
409400
410401 assertLabel (
411- [ 'Solid' , 'Incoming flow count: 4' , 'Outgoing flow count: 3' , '447TWh' ] ,
402+ [ 'Solid' , 'incoming flow count: 4' , 'outgoing flow count: 3' , '447TWh' ] ,
412403 [ 'rgb(148, 103, 189)' , 'rgb(255, 255, 255)' , 13 , 'Roboto' , 'rgb(255, 255, 255)' ]
413404 ) ;
414405 } )
415406 . then ( function ( ) {
416407 _hover ( 450 , 300 ) ;
417408
418409 assertLabel (
419- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
410+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
420411 [ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Roboto' , 'rgb(255, 255, 255)' ]
421412 ) ;
422413
@@ -431,15 +422,15 @@ describe('sankey tests', function() {
431422 _hover ( 404 , 302 ) ;
432423
433424 assertLabel (
434- [ 'Solid' , 'Incoming flow count: 4' , 'Outgoing flow count: 3' , '447TWh' ] ,
425+ [ 'Solid' , 'incoming flow count: 4' , 'outgoing flow count: 3' , '447TWh' ] ,
435426 [ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' , 20 , 'Roboto' , 'rgb(0, 0, 0)' ]
436427 ) ;
437428 } )
438429 . then ( function ( ) {
439430 _hover ( 450 , 300 ) ;
440431
441432 assertLabel (
442- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
433+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
443434 [ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' , 20 , 'Roboto' , 'rgb(0, 0, 0)' ]
444435 ) ;
445436 } )
@@ -463,7 +454,7 @@ describe('sankey tests', function() {
463454 _hover ( 450 , 300 ) ;
464455
465456 assertLabel (
466- [ 'Source : Solid' , 'Target : Industry' , '46TWh' ] ,
457+ [ 'source : Solid' , 'target : Industry' , '46TWh' ] ,
467458 [ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
468459 ) ;
469460 } )
0 commit comments