1
1
import uut from '../colors' ;
2
2
const SYSTEM_COLORS = [ 'grey' , 'white' , 'black' ] ;
3
+ const GetColorsByHexOptions = { validColors : SYSTEM_COLORS } ;
3
4
4
5
describe ( 'style/Colors' , ( ) => {
5
6
it ( 'should add alpha to hex color value' , ( ) => {
@@ -194,15 +195,15 @@ describe('style/Colors', () => {
194
195
195
196
describe ( 'getSystemColorByHex' , ( ) => {
196
197
it ( 'should return the system color, if the color is included in the validColors array' , ( ) => {
197
- expect ( uut . getSystemColorByHex ( '#FFFFFF' , SYSTEM_COLORS ) ) . toEqual ( 'white' ) ;
198
- expect ( uut . getSystemColorByHex ( '#000000' , SYSTEM_COLORS ) ) . toEqual ( 'black' ) ;
199
- expect ( uut . getSystemColorByHex ( '#116DFF' , [ ...SYSTEM_COLORS , 'blue' ] ) ) . toEqual ( 'blue30' ) ;
200
- expect ( uut . getSystemColorByHex ( '#FB6413' , [ ...SYSTEM_COLORS , 'orange' ] ) ) . toEqual ( 'orange30' ) ;
198
+ expect ( uut . getSystemColorByHex ( '#FFFFFF' , GetColorsByHexOptions ) ) . toEqual ( 'white' ) ;
199
+ expect ( uut . getSystemColorByHex ( '#000000' , GetColorsByHexOptions ) ) . toEqual ( 'black' ) ;
200
+ expect ( uut . getSystemColorByHex ( '#116DFF' , { validColors : [ ...SYSTEM_COLORS , 'blue' ] } ) ) . toEqual ( 'blue30' ) ;
201
+ expect ( uut . getSystemColorByHex ( '#FB6413' , { validColors : [ ...SYSTEM_COLORS , 'orange' ] } ) ) . toEqual ( 'orange30' ) ;
201
202
} ) ;
202
203
203
204
it ( 'should return undefined if the color is not included in validColors' , ( ) => {
204
- expect ( uut . getSystemColorByHex ( '#116DFF' , SYSTEM_COLORS ) ) . toEqual ( undefined ) ;
205
- expect ( uut . getSystemColorByHex ( '#00A87E' , SYSTEM_COLORS ) ) . toEqual ( undefined ) ;
205
+ expect ( uut . getSystemColorByHex ( '#116DFF' , GetColorsByHexOptions ) ) . toEqual ( undefined ) ;
206
+ expect ( uut . getSystemColorByHex ( '#00A87E' , GetColorsByHexOptions ) ) . toEqual ( undefined ) ;
206
207
} ) ;
207
208
208
209
it ( 'without validColors array the function will return the first system color name match the color' , ( ) => {
@@ -212,8 +213,8 @@ describe('style/Colors', () => {
212
213
213
214
it ( 'should return undefined for color that does not exist in our colors palette.' , ( ) => {
214
215
expect ( uut . getSystemColorByHex ( '#5A48F5' ) ) . toEqual ( 'violet30' ) ;
215
- expect ( uut . getSystemColorByHex ( '#5A48F5' , SYSTEM_COLORS ) ) . toEqual ( undefined ) ;
216
- expect ( uut . getSystemColorByHex ( '#5A48F5' , [ 'primary' ] ) ) . toEqual ( 'primary' ) ;
216
+ expect ( uut . getSystemColorByHex ( '#5A48F5' , GetColorsByHexOptions ) ) . toEqual ( undefined ) ;
217
+ expect ( uut . getSystemColorByHex ( '#5A48F5' , { validColors : [ ... SYSTEM_COLORS , 'primary' ] } ) ) . toEqual ( 'primary' ) ;
217
218
} ) ;
218
219
} ) ;
219
220
} ) ;
0 commit comments