@@ -25,18 +25,46 @@ const baseProps: RadarSvgProps<TestDatum> = {
25
25
it ( 'should render a basic radar chart' , ( ) => {
26
26
const wrapper = mount ( < Radar < TestDatum > { ...baseProps } /> )
27
27
28
- const shapes = wrapper . find ( 'RadarShapes' )
29
- expect ( shapes ) . toHaveLength ( 2 )
30
-
31
- const shape0 = shapes . at ( 0 )
32
- expect ( shape0 . prop ( 'item' ) ) . toBe ( 'A' )
33
- const shape0path = shape0 . find ( 'path' )
34
- expect ( shape0path . prop ( 'fill' ) ) . toBe ( 'rgba(232, 193, 160, 1)' )
35
-
36
- const shape1 = shapes . at ( 1 )
37
- expect ( shape1 . prop ( 'item' ) ) . toBe ( 'B' )
38
- const shape1path = shape1 . find ( 'path' )
39
- expect ( shape1path . prop ( 'fill' ) ) . toBe ( 'rgba(244, 117, 96, 1)' )
28
+ const layers = wrapper . find ( 'RadarLayer' )
29
+ expect ( layers ) . toHaveLength ( 2 )
30
+
31
+ const layer0 = layers . at ( 0 )
32
+ expect ( layer0 . prop ( 'item' ) ) . toBe ( 'A' )
33
+ const layer0path = layer0 . find ( 'path' )
34
+ expect ( layer0path . prop ( 'fill' ) ) . toBe ( 'rgba(232, 193, 160, 1)' )
35
+
36
+ const layer1 = layers . at ( 1 )
37
+ expect ( layer1 . prop ( 'item' ) ) . toBe ( 'B' )
38
+ const layer1path = layer1 . find ( 'path' )
39
+ expect ( layer1path . prop ( 'fill' ) ) . toBe ( 'rgba(244, 117, 96, 1)' )
40
+ } )
41
+
42
+ describe ( 'data' , ( ) => {
43
+ it ( 'should support value formatting' , ( ) => {
44
+ const wrapper = mount (
45
+ < Radar < TestDatum > { ...baseProps } valueFormat = { value => `${ value } %` } />
46
+ )
47
+
48
+ wrapper . find ( 'RadarSlice' ) . at ( 0 ) . find ( 'path' ) . simulate ( 'mouseenter' )
49
+
50
+ const tooltip = wrapper . find ( 'RadarSliceTooltip' )
51
+ const data = tooltip . prop < RadarSliceTooltipProps [ 'data' ] > ( 'data' )
52
+ expect ( data [ 0 ] . formattedValue ) . toEqual ( '20%' )
53
+ expect ( data [ 1 ] . formattedValue ) . toEqual ( '10%' )
54
+ } )
55
+
56
+ it ( 'should support value formatting depending on the key' , ( ) => {
57
+ const wrapper = mount (
58
+ < Radar < TestDatum > { ...baseProps } valueFormat = { ( value , key ) => `${ value } ${ key } s` } />
59
+ )
60
+
61
+ wrapper . find ( 'RadarSlice' ) . at ( 2 ) . find ( 'path' ) . simulate ( 'mouseenter' )
62
+
63
+ const tooltip = wrapper . find ( 'RadarSliceTooltip' )
64
+ const data = tooltip . prop < RadarSliceTooltipProps [ 'data' ] > ( 'data' )
65
+ expect ( data [ 0 ] . formattedValue ) . toEqual ( '30 As' )
66
+ expect ( data [ 1 ] . formattedValue ) . toEqual ( '10 Bs' )
67
+ } )
40
68
} )
41
69
42
70
describe ( 'tooltip' , ( ) => {
@@ -90,8 +118,8 @@ describe('style', () => {
90
118
const colors = [ 'rgba(255, 0, 0, 1)' , 'rgba(0, 0, 255, 1)' ]
91
119
const wrapper = mount ( < Radar { ...baseProps } colors = { colors } /> )
92
120
93
- expect ( wrapper . find ( 'RadarShapes ' ) . at ( 0 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colors [ 0 ] )
94
- expect ( wrapper . find ( 'RadarShapes ' ) . at ( 1 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colors [ 1 ] )
121
+ expect ( wrapper . find ( 'RadarLayer ' ) . at ( 0 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colors [ 0 ] )
122
+ expect ( wrapper . find ( 'RadarLayer ' ) . at ( 1 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colors [ 1 ] )
95
123
} )
96
124
97
125
it ( 'custom colors function' , ( ) => {
@@ -106,8 +134,8 @@ describe('style', () => {
106
134
/>
107
135
)
108
136
109
- expect ( wrapper . find ( 'RadarShapes ' ) . at ( 0 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colorMapping . A )
110
- expect ( wrapper . find ( 'RadarShapes ' ) . at ( 1 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colorMapping . B )
137
+ expect ( wrapper . find ( 'RadarLayer ' ) . at ( 0 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colorMapping . A )
138
+ expect ( wrapper . find ( 'RadarLayer ' ) . at ( 1 ) . find ( 'path' ) . prop ( 'fill' ) ) . toBe ( colorMapping . B )
111
139
} )
112
140
} )
113
141
0 commit comments