@@ -58,11 +58,11 @@ describe('Meter', () => {
58
58
} ) ;
59
59
60
60
it ( 'computes barStyle' , ( ) => {
61
- expect ( meter . find ( '.bar' ) . prop ( 'style' ) . backgroundColor ) . toBe ( ranges [ 0 ] . backgroundColor ) ;
61
+ expect ( meter . find ( '.bar' ) . prop ( 'style' ) . background ) . toBe ( ranges [ 0 ] . backgroundColor ) ;
62
62
} ) ;
63
63
64
64
it ( 'computes fillingStyle' , ( ) => {
65
- expect ( meter . find ( '.filling' ) . prop ( 'style' ) . backgroundColor ) . toBe ( ranges [ 0 ] . fillingColor ) ;
65
+ expect ( meter . find ( '.filling' ) . prop ( 'style' ) . background ) . toBe ( ranges [ 0 ] . fillingColor ) ;
66
66
} ) ;
67
67
68
68
it ( 'computes labelStyle' , ( ) => {
@@ -94,7 +94,7 @@ describe('Meter', () => {
94
94
const meter = shallow (
95
95
< Meter value = { 60 } ranges = { ranges } />
96
96
) ;
97
- expect ( meter . find ( '.filling' ) . prop ( 'style' ) . backgroundColor ) . toBe ( ranges [ 0 ] . fillingColor ) ;
97
+ expect ( meter . find ( '.filling' ) . prop ( 'style' ) . background ) . toBe ( ranges [ 0 ] . fillingColor ) ;
98
98
} ) ;
99
99
100
100
it ( 'defaults to the base color as background color if there\'s no matching range' , ( ) => {
@@ -104,7 +104,7 @@ describe('Meter', () => {
104
104
const meter = shallow (
105
105
< Meter value = { 20 } ranges = { ranges } baseFillingColor = '#ccc' />
106
106
) ;
107
- expect ( meter . find ( '.filling' ) . prop ( 'style' ) . backgroundColor ) . toBe ( '#ccc' ) ;
107
+ expect ( meter . find ( '.filling' ) . prop ( 'style' ) . background ) . toBe ( '#ccc' ) ;
108
108
} ) ;
109
109
110
110
it ( 'doesn\'t define a background color if there\'s no matching range and no default is given' , ( ) => {
@@ -114,7 +114,7 @@ describe('Meter', () => {
114
114
const meter = shallow (
115
115
< Meter value = { 20 } ranges = { ranges } />
116
116
) ;
117
- expect ( meter . find ( '.filling' ) . prop ( 'style' ) . backgroundColor ) . toBeUndefined ( ) ;
117
+ expect ( meter . find ( '.filling' ) . prop ( 'style' ) . background ) . toBeUndefined ( ) ;
118
118
} ) ;
119
119
120
120
it ( 'defaults to base color as bar background color should if there\'s no matching range' , ( ) => {
@@ -124,7 +124,7 @@ describe('Meter', () => {
124
124
const meter = shallow (
125
125
< Meter value = { 20 } ranges = { ranges } baseBackgroundColor = '#ccc' />
126
126
) ;
127
- expect ( meter . find ( '.bar' ) . prop ( 'style' ) . backgroundColor ) . toBe ( '#ccc' ) ;
127
+ expect ( meter . find ( '.bar' ) . prop ( 'style' ) . background ) . toBe ( '#ccc' ) ;
128
128
} ) ;
129
129
130
130
it ( 'doesn\'t define a bar background color if there\'s no matching range and no default is given' , ( ) => {
@@ -134,7 +134,31 @@ describe('Meter', () => {
134
134
const meter = shallow (
135
135
< Meter value = { 20 } ranges = { ranges } />
136
136
) ;
137
- expect ( meter . find ( '.bar' ) . prop ( 'style' ) . backgroundColor ) . toBeUndefined ( ) ;
137
+ expect ( meter . find ( '.bar' ) . prop ( 'style' ) . background ) . toBeUndefined ( ) ;
138
+ } ) ;
139
+
140
+ it ( 'computes colors respecting base colors' , ( ) => {
141
+ const ranges = [
142
+ { startValue : 0 , endValue : 50 , fillingColor : 'yellow' } ,
143
+ { startValue : 50 , endValue : 80 }
144
+ ] ;
145
+ const baseColors = {
146
+ baseBackgroundColor : 'red' ,
147
+ baseFillingColor : 'green' ,
148
+ baseLabelColor : 'blue' ,
149
+ } ;
150
+ const meter1 = shallow (
151
+ < Meter value = { 30 } ranges = { ranges } { ...baseColors } />
152
+ ) ;
153
+ expect ( meter1 . find ( '.bar' ) . prop ( 'style' ) . background ) . toBe ( 'red' ) ;
154
+ expect ( meter1 . find ( '.filling' ) . prop ( 'style' ) . background ) . toBe ( 'yellow' ) ;
155
+ expect ( meter1 . find ( '.label' ) . prop ( 'style' ) . color ) . toBe ( 'blue' ) ;
156
+ const meter2 = shallow (
157
+ < Meter value = { 60 } ranges = { ranges } { ...baseColors } />
158
+ ) ;
159
+ expect ( meter2 . find ( '.bar' ) . prop ( 'style' ) . background ) . toBe ( 'red' ) ;
160
+ expect ( meter2 . find ( '.filling' ) . prop ( 'style' ) . background ) . toBe ( 'green' ) ;
161
+ expect ( meter2 . find ( '.label' ) . prop ( 'style' ) . color ) . toBe ( 'blue' ) ;
138
162
} ) ;
139
163
140
164
} ) ;
0 commit comments