@@ -21,6 +21,20 @@ describe('DonutChart', () => {
21
21
expect ( render ( < DonutChart data = { mockData } /> ) ) . toBeTruthy ( )
22
22
} )
23
23
24
+ it ( 'should not render donut with empty data' , ( ) => {
25
+ const { container } = render ( < DonutChart data = { [ ] } name = "test" /> )
26
+ expect ( container ) . toBeEmptyDOMElement ( )
27
+ } )
28
+
29
+ it ( 'should not render donut with 0 values' , ( ) => {
30
+ const mockData : ChartData [ ] = [
31
+ { value : 0 , name : 'A' , color : [ 0 , 0 , 0 ] } ,
32
+ { value : 0 , name : 'B' , color : [ 10 , 10 , 10 ] } ,
33
+ ]
34
+ const { container } = render ( < DonutChart data = { mockData } name = "test" /> )
35
+ expect ( container ) . toBeEmptyDOMElement ( )
36
+ } )
37
+
24
38
it ( 'should render svg' , ( ) => {
25
39
render ( < DonutChart data = { mockData } name = "test" /> )
26
40
expect ( screen . getByTestId ( 'donut-test' ) ) . toBeInTheDocument ( )
@@ -34,6 +48,16 @@ describe('DonutChart', () => {
34
48
} )
35
49
} )
36
50
51
+ it ( 'should not render arcs and labels with 0 value' , ( ) => {
52
+ const mockData : ChartData [ ] = [
53
+ { value : 0 , name : 'A' , color : [ 0 , 0 , 0 ] } ,
54
+ { value : 10 , name : 'B' , color : [ 10 , 10 , 10 ] } ,
55
+ ]
56
+ render ( < DonutChart data = { mockData } /> )
57
+ expect ( screen . queryByTestId ( 'arc-A-0' ) ) . not . toBeInTheDocument ( )
58
+ expect ( screen . queryByTestId ( 'label-A-0' ) ) . not . toBeInTheDocument ( )
59
+ } )
60
+
37
61
it ( 'should do not render label value if value less than 5%' , ( ) => {
38
62
render ( < DonutChart data = { mockData } config = { { percentToShowLabel : 5 } } /> )
39
63
expect ( screen . getByTestId ( 'label-A-1' ) ) . toHaveTextContent ( '' )
0 commit comments