@@ -106,7 +106,10 @@ describe('PoChartCircular:', () => {
106106
107107 spyOn ( PoChartCircular , < any > 'calculateEndAngle' ) . and . returnValues ( ...itemsEndAngle ) ;
108108
109- component [ 'series' ] = [ { value : 1 } , { value : 2 } , { value : 3 } , { value : 4 } ] ;
109+ component . colors = PoChartColors [ 3 ] ;
110+ component [ 'series' ] = [
111+ { category : '1' , value : 1 } , { category : '2' , value : 2 } , { category : '3' , value : 3 } , { category : '4' , value : 4 }
112+ ] ;
110113
111114 component [ 'calculateAngleRadians' ] ( ) ;
112115
@@ -117,7 +120,10 @@ describe('PoChartCircular:', () => {
117120 spyOn ( PoChartCircular , < any > 'calculateEndAngle' ) ;
118121 component [ 'totalValue' ] = 24 ;
119122
120- component [ 'series' ] = [ { value : 1 } , { value : 2 } , { value : 3 } , { value : 4 } ] ;
123+ component . colors = PoChartColors [ 3 ] ;
124+ component [ 'series' ] = [
125+ { category : '1' , value : 1 } , { category : '2' , value : 2 } , { category : '3' , value : 3 } , { category : '4' , value : 4 }
126+ ] ;
121127
122128 component [ 'calculateAngleRadians' ] ( ) ;
123129
@@ -196,7 +202,7 @@ describe('PoChartCircular:', () => {
196202 spyOn ( component [ 'renderer' ] , 'setAttribute' ) ;
197203 spyOn ( component [ 'renderer' ] , 'appendChild' ) ;
198204
199- component [ 'createPath' ] ( index , serie , svgPathsWrapper ) ;
205+ component [ 'createPath' ] ( serie , svgPathsWrapper ) ;
200206
201207 expect ( component [ 'renderer' ] . setAttribute ) . toHaveBeenCalledTimes ( 5 ) ;
202208 expect ( component [ 'renderer' ] . appendChild ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -216,7 +222,7 @@ describe('PoChartCircular:', () => {
216222 spyOn ( component [ 'renderer' ] , 'appendChild' ) ;
217223 spyOn ( component , < any > 'setTooltipAttributes' ) ;
218224
219- component [ 'createPath' ] ( index , serie , svgPathsWrapper ) ;
225+ component [ 'createPath' ] ( serie , svgPathsWrapper ) ;
220226
221227 expect ( component [ 'setTooltipAttributes' ] ) . toHaveBeenCalledWith ( svgPath , serie ) ;
222228 } ) ;
@@ -385,6 +391,7 @@ describe('PoChartCircular:', () => {
385391 } ) ;
386392
387393 it ( 'createPaths: should call `renderer.createElement` and call `createPath`' , ( ) => {
394+ component . colors = PoChartColors [ 2 ] ;
388395 component [ 'series' ] = [ { value : 10 , category : 'First' } , { value : 20 , category : 'Second' } ] ;
389396
390397 spyOn ( component [ 'renderer' ] , 'createElement' ) ;
@@ -398,9 +405,12 @@ describe('PoChartCircular:', () => {
398405 expect ( component [ 'createPath' ] ) . toHaveBeenCalled ( ) ;
399406 } ) ;
400407
401- it ( 'createSVGElements: should create svgElement and call `createPaths`, append svgElement in svgContainer and setAttributes' , ( ) => {
402-
408+ it ( `createSVGElements: should create svgElement and call 'createPaths', 'createTexts',
409+ append svgElement in svgContainer and setAttributes` , ( ) => {
410+ component . colors = PoChartColors [ 0 ] ;
411+ component . series = [ { category : 'po' , value : 1 } ] ;
403412 spyOn ( component , < any > 'createPaths' ) ;
413+ spyOn ( component , < any > 'createTexts' ) ;
404414 spyOn ( component [ 'renderer' ] , < any > 'createElement' ) . and . callThrough ( ) ;
405415 spyOn ( component [ 'renderer' ] , < any > 'setAttribute' ) ;
406416 spyOn ( component [ 'svgContainer' ] . nativeElement , < any > 'appendChild' ) ;
@@ -409,6 +419,7 @@ describe('PoChartCircular:', () => {
409419
410420 expect ( component . svgElement ) . toBeDefined ( ) ;
411421 expect ( component [ 'createPaths' ] ) . toHaveBeenCalled ( ) ;
422+ expect ( component [ 'createTexts' ] ) . toHaveBeenCalled ( ) ;
412423 expect ( component [ 'renderer' ] . createElement ) . toHaveBeenCalledWith ( 'svg:svg' , 'svg' ) ;
413424 expect ( component [ 'renderer' ] . setAttribute ) . toHaveBeenCalledTimes ( 5 ) ;
414425 expect ( component [ 'svgContainer' ] . nativeElement . appendChild ) . toHaveBeenCalledWith ( component . svgElement ) ;
@@ -611,6 +622,7 @@ describe('PoChartCircular:', () => {
611622 { value : 20 , category : 'Second' }
612623 ] ;
613624
625+ component . colors = PoChartColors [ mockSeries . length ] ;
614626 component [ 'series' ] = mockSeries ;
615627 component . type = PoChartType . Donut ;
616628
@@ -627,6 +639,7 @@ describe('PoChartCircular:', () => {
627639 { value : 20 , category : 'Second' }
628640 ] ;
629641
642+ component . colors = PoChartColors [ mockSeries . length ] ;
630643 component [ 'series' ] = mockSeries ;
631644 component . type = PoChartType . Donut ;
632645
@@ -638,7 +651,6 @@ describe('PoChartCircular:', () => {
638651 } ) ;
639652
640653 it ( 'createText: should create a svg text element with some attributes and add it into `svgTextElementsList`' , ( ) => {
641- const index = 0 ;
642654 const serie : PoDonutChartSeries = { category : 'po' , value : 2 } ;
643655
644656 component . colors = PoChartColors [ 0 ] ;
@@ -652,7 +664,7 @@ describe('PoChartCircular:', () => {
652664 spyOn ( component [ 'renderer' ] , 'setAttribute' ) ;
653665 spyOn ( component [ 'renderer' ] , 'appendChild' ) ;
654666
655- component [ 'createText' ] ( index , serie ) ;
667+ component [ 'createText' ] ( serie ) ;
656668
657669 expect ( component [ 'getFontSize' ] ) . toHaveBeenCalled ( ) ;
658670 expect ( component [ 'getTextColor' ] ) . toHaveBeenCalled ( ) ;
@@ -661,7 +673,7 @@ describe('PoChartCircular:', () => {
661673
662674 expect ( component [ 'renderer' ] . createElement ) . toHaveBeenCalledTimes ( 2 ) ;
663675 expect ( component [ 'renderer' ] . setAttribute ) . toHaveBeenCalledTimes ( 4 ) ;
664- expect ( component [ 'renderer' ] . appendChild ) . toHaveBeenCalledTimes ( 1 ) ;
676+ expect ( component [ 'renderer' ] . appendChild ) . toHaveBeenCalledTimes ( 2 ) ;
665677
666678 expect ( component [ 'svgTextElementsList' ] . length ) . toEqual ( 1 ) ;
667679 } ) ;
@@ -736,6 +748,35 @@ describe('PoChartCircular:', () => {
736748 expect ( component . innerRadius ) . toBe ( expectedValue ) ;
737749 } ) ;
738750
751+ it ( 'getSeriesWithValue: should return only series with value and color attr' , ( ) => {
752+ const invalidSeries = [ { category : 'Valor 0' , value : 0 } ] ;
753+ const series = [ { category : 'Valor 2' , value : 2 } , { category : 'Valor 3' , value : 3 } ] ;
754+ const seriesParam = [ ...series , ...invalidSeries ] ;
755+
756+ component . colors = PoChartColors [ seriesParam . length ] ;
757+
758+ const validSeries = component [ 'getSeriesWithValue' ] ( seriesParam ) ;
759+
760+ expect ( validSeries . length ) . toEqual ( series . length ) ;
761+ expect ( validSeries . every ( serie => ! ! serie . color ) ) . toBe ( true ) ;
762+ } ) ;
763+
764+ it ( 'getSeriesWithValue: should return empty array if series has value 0' , ( ) => {
765+ const invalidSeries = [ { category : 'Valor 0' , value : 0 } ] ;
766+
767+ const validSeries = component [ 'getSeriesWithValue' ] ( invalidSeries ) ;
768+
769+ expect ( validSeries ) . toEqual ( [ ] ) ;
770+ } ) ;
771+
772+ it ( 'getSeriesWithValue: should return empty array if series has value -1' , ( ) => {
773+ const invalidSeries = [ { category : 'Valor -1' , value : - 1 } ] ;
774+
775+ const validSeries = component [ 'getSeriesWithValue' ] ( invalidSeries ) ;
776+
777+ expect ( validSeries ) . toEqual ( [ ] ) ;
778+ } ) ;
779+
739780 } ) ;
740781
741782} ) ;
0 commit comments