@@ -21,10 +21,10 @@ const gradientColor = {
21
21
] ,
22
22
} ;
23
23
24
- const colorTests = ( colorProp , color , selector , fill = false ) => {
24
+ const colorAsStringTests = ( colorProp , color , selector , fill = false ) => {
25
25
describe ( "applies color as string" , ( ) => {
26
26
const wrapper = localFactory ( { ...colorProp } ) ;
27
- const circleProgressWrapper = wrapper . find ( selector ) ;
27
+ const circleWrapper = wrapper . find ( selector ) ;
28
28
29
29
it ( "do not recognize gradient colors" , ( ) => {
30
30
const type = selector . includes ( "empty" ) ? "EmptyColor" : "Color" ;
@@ -37,12 +37,12 @@ const colorTests = (colorProp, color, selector, fill = false) => {
37
37
} ) ;
38
38
39
39
it ( "applies color correctly to SVG stroke" , ( ) => {
40
- expect ( circleProgressWrapper . element . getAttribute ( `${ fill ? "fill" : "stroke" } ` ) ) . to . equal ( `${ color } ` ) ;
40
+ expect ( circleWrapper . element . getAttribute ( `${ fill ? "fill" : "stroke" } ` ) ) . to . equal ( `${ color } ` ) ;
41
41
} ) ;
42
42
} ) ;
43
43
} ;
44
44
45
- const gradientColorTests = ( colorProp , selector , urlPrefix , fill = false ) => {
45
+ const gradientColorTests = ( colorProp , selector , gradientURLPrefix , fill = false ) => {
46
46
describe ( "applies gradient color correctly" , ( ) => {
47
47
const wrapper = localFactory ( colorProp ) ;
48
48
const circleWrapper = wrapper . find ( selector ) ;
@@ -59,7 +59,7 @@ const gradientColorTests = (colorProp, selector, urlPrefix, fill = false) => {
59
59
} ) ;
60
60
it ( `applies gradient URL to SVG ${ fill ? "fill" : "stroke" } ` , ( ) => {
61
61
expect ( circleWrapper . element . getAttribute ( `${ fill ? "fill" : "stroke" } ` ) ) . to . equal (
62
- `url(#${ urlPrefix } -gradient-${ id } )`
62
+ `url(#${ gradientURLPrefix } -gradient-${ id } )`
63
63
) ;
64
64
} ) ;
65
65
it ( "renders corresponding amount of stop colors SVG elements" , ( ) => {
@@ -81,23 +81,73 @@ const gradientColorTests = (colorProp, selector, urlPrefix, fill = false) => {
81
81
} ) ;
82
82
} ;
83
83
84
- describe ( "#color" , ( ) => {
84
+ const colorTests = ( colorProp , half = false , empty = false , gradientURLPrefix ) => {
85
+ const circleClassPrefix = `ep-${ half ? "half-" : "" } circle--` ;
86
+ const circleClassPostfix = `${ empty ? "empty" : "progress" } ` ;
87
+ const circleSelector = `.${ circleClassPrefix } ${ circleClassPostfix } ` ;
88
+
85
89
const color = "#ff0020" ;
86
- colorTests ( { color } , color , "circle.ep-circle--progress" ) ;
87
- gradientColorTests ( { color : gradientColor } , "circle.ep-circle--progress" , "ep-progress" ) ;
88
- } ) ;
89
- describe ( "#emptyColor" , ( ) => {
90
- const emptyColor = "#a617ff" ;
91
- colorTests ( { emptyColor } , emptyColor , "circle.ep-circle--empty" ) ;
92
- gradientColorTests ( { emptyColor : gradientColor } , "circle.ep-circle--empty" , "ep-empty" ) ;
93
- } ) ;
94
- describe ( "#colorFill" , ( ) => {
95
- const colorFill = "#fff149" ;
96
- colorTests ( { colorFill } , colorFill , "circle.ep-circle--progress" , true ) ;
97
- gradientColorTests ( { colorFill : gradientColor } , "circle.ep-circle--progress" , "ep-progress-fill" , true ) ;
98
- } ) ;
99
- describe ( "#emptyColorFill" , ( ) => {
100
- const emptyColorFill = "#3f79ff" ;
101
- colorTests ( { emptyColorFill } , emptyColorFill , "circle.ep-circle--empty" , true ) ;
102
- gradientColorTests ( { emptyColorFill : gradientColor } , "circle.ep-circle--empty" , "ep-empty-fill" , true ) ;
90
+
91
+ it ( "does not render fill circle" , ( ) => {
92
+ expect (
93
+ localFactory ( { [ colorProp ] : color } )
94
+ . find ( `.ep-${ half ? "half-" : "" } circle--${ empty ? "empty" : "progress" } __fill` )
95
+ . exists ( )
96
+ ) . to . be . false ;
97
+ } ) ;
98
+
99
+ colorAsStringTests ( { [ colorProp ] : color } , color , circleSelector , false ) ;
100
+ gradientColorTests ( { [ colorProp ] : gradientColor } , circleSelector , gradientURLPrefix , false ) ;
101
+ } ;
102
+
103
+ const colorFillTests = ( colorProp , half = false , empty = false , gradientURLPrefix ) => {
104
+ const circleClassPrefix = `ep-${ half ? "half-" : "" } circle--` ;
105
+ const circleClassPostfix = `${ empty ? "empty" : "progress" } __fill` ;
106
+ const circleSelector = `.${ circleClassPrefix } ${ circleClassPostfix } ` ;
107
+
108
+ const color = "#ff0020" ;
109
+
110
+ it ( "renders fill circle" , ( ) => {
111
+ expect (
112
+ localFactory ( { [ colorProp ] : color } )
113
+ . find ( circleSelector )
114
+ . exists ( )
115
+ ) . to . be . true ;
116
+ } ) ;
117
+
118
+ colorAsStringTests ( { [ colorProp ] : color } , color , circleSelector , true ) ;
119
+ gradientColorTests ( { [ colorProp ] : gradientColor } , circleSelector , gradientURLPrefix , true ) ;
120
+ } ;
121
+
122
+ describe ( "Colors" , ( ) => {
123
+ describe ( "Circle" , ( ) => {
124
+ const half = false ;
125
+ describe ( "#color" , ( ) => {
126
+ colorTests ( "color" , half , false , "ep-progress" ) ;
127
+ } ) ;
128
+ describe ( "#emptyColor" , ( ) => {
129
+ colorTests ( "emptyColor" , half , true , "ep-empty" ) ;
130
+ } ) ;
131
+ describe ( "#colorFill" , ( ) => {
132
+ colorFillTests ( "colorFill" , half , false , "ep-progress-fill" ) ;
133
+ } ) ;
134
+ describe ( "#emptyColorFill" , ( ) => {
135
+ colorFillTests ( "emptyColorFill" , half , true , "ep-empty-fill" ) ;
136
+ } ) ;
137
+ } ) ;
138
+ describe ( "Half Circle" , ( ) => {
139
+ const half = true ;
140
+ describe ( "#color" , ( ) => {
141
+ colorTests ( "color" , half , false , "ep-progress" ) ;
142
+ } ) ;
143
+ describe ( "#emptyColor" , ( ) => {
144
+ colorTests ( "emptyColor" , half , true , "ep-empty" ) ;
145
+ } ) ;
146
+ describe ( "#colorFill" , ( ) => {
147
+ colorFillTests ( "colorFill" , half , false , "ep-progress-fill" ) ;
148
+ } ) ;
149
+ describe ( "#emptyColorFill" , ( ) => {
150
+ colorFillTests ( "emptyColorFill" , half , true , "ep-empty-fill" ) ;
151
+ } ) ;
152
+ } ) ;
103
153
} ) ;
0 commit comments