55 * found at http://www.apache.org/licenses/LICENSE-2.0.
66 */
77
8- import { getColor } from './_getColor ' ;
8+ import { getColorV8 } from './getColorV8 ' ;
99import PALETTE from '../elements/palette' ;
1010import DEFAULT_THEME from '../elements/theme' ;
1111import { darken , lighten , rgba } from 'polished' ;
1212
1313const DEFAULT_SHADE = 600 ;
1414
15- describe ( '_getColor ' , ( ) => {
15+ describe ( 'getColorV8 ' , ( ) => {
1616 describe ( 'by hue' , ( ) => {
1717 it ( 'gets the hue specified by string' , ( ) => {
18- const color = getColor ( 'red' ) ;
18+ const color = getColorV8 ( 'red' ) ;
1919 const expected = PALETTE . red [ DEFAULT_SHADE ] ;
2020
2121 expect ( color ) . toBe ( expected ) ;
2222 } ) ;
2323
2424 it ( 'gets the hue specified by object' , ( ) => {
25- const color = getColor ( PALETTE . green ) ;
25+ const color = getColorV8 ( PALETTE . green ) ;
2626 const expected = PALETTE . green [ DEFAULT_SHADE ] ;
2727
2828 expect ( color ) . toBe ( expected ) ;
2929 } ) ;
3030
3131 it ( 'falls back when the hue is off palette' , ( ) => {
3232 const expected = 'orchid' ;
33- const color = getColor ( expected ) ;
33+ const color = getColorV8 ( expected ) ;
3434
3535 expect ( color ) . toBe ( expected ) ;
3636 } ) ;
3737
3838 describe ( 'by `color` key' , ( ) => {
3939 it ( 'gets the default background color' , ( ) => {
40- const color = getColor ( 'background' ) ;
40+ const color = getColorV8 ( 'background' ) ;
4141 const expected = DEFAULT_THEME . colors . background ;
4242
4343 expect ( color ) . toBe ( expected ) ;
4444 } ) ;
4545
4646 it ( 'gets the default foreground color' , ( ) => {
47- const color = getColor ( 'foreground' ) ;
47+ const color = getColorV8 ( 'foreground' ) ;
4848 const expected = DEFAULT_THEME . colors . foreground ;
4949
5050 expect ( color ) . toBe ( expected ) ;
5151 } ) ;
5252
5353 it ( 'gets the default primary color' , ( ) => {
54- const color = getColor ( 'primaryHue' ) ;
54+ const color = getColorV8 ( 'primaryHue' ) ;
5555 const expected = ( PALETTE as any ) [ DEFAULT_THEME . colors . primaryHue ] [ DEFAULT_SHADE ] ;
5656
5757 expect ( color ) . toBe ( expected ) ;
5858 } ) ;
5959
6060 it ( 'gets the default danger color' , ( ) => {
61- const color = getColor ( 'dangerHue' ) ;
61+ const color = getColorV8 ( 'dangerHue' ) ;
6262 const expected = ( PALETTE as any ) [ DEFAULT_THEME . colors . dangerHue ] [ DEFAULT_SHADE ] ;
6363
6464 expect ( color ) . toBe ( expected ) ;
6565 } ) ;
6666
6767 it ( 'gets the default warning color' , ( ) => {
68- const color = getColor ( 'warningHue' ) ;
68+ const color = getColorV8 ( 'warningHue' ) ;
6969 const expected = ( PALETTE as any ) [ DEFAULT_THEME . colors . warningHue ] [ DEFAULT_SHADE ] ;
7070
7171 expect ( color ) . toBe ( expected ) ;
7272 } ) ;
7373
7474 it ( 'gets the default success color' , ( ) => {
75- const color = getColor ( 'successHue' ) ;
75+ const color = getColorV8 ( 'successHue' ) ;
7676 const expected = ( PALETTE as any ) [ DEFAULT_THEME . colors . successHue ] [ DEFAULT_SHADE ] ;
7777
7878 expect ( color ) . toBe ( expected ) ;
7979 } ) ;
8080
8181 it ( 'gets the default neutral color' , ( ) => {
82- const color = getColor ( 'neutralHue' ) ;
82+ const color = getColorV8 ( 'neutralHue' ) ;
8383 const expected = ( PALETTE as any ) [ DEFAULT_THEME . colors . neutralHue ] [ DEFAULT_SHADE ] ;
8484
8585 expect ( color ) . toBe ( expected ) ;
8686 } ) ;
8787
8888 it ( 'gets the default chrome color' , ( ) => {
89- const color = getColor ( 'chromeHue' ) ;
89+ const color = getColorV8 ( 'chromeHue' ) ;
9090 const expected = ( PALETTE as any ) [ DEFAULT_THEME . colors . chromeHue ] [ DEFAULT_SHADE ] ;
9191
9292 expect ( color ) . toBe ( expected ) ;
@@ -96,44 +96,44 @@ describe('_getColor', () => {
9696
9797 describe ( 'by shade' , ( ) => {
9898 it ( 'gets the specified shade of hue' , ( ) => {
99- const color = getColor ( 'red' , 100 ) ;
99+ const color = getColorV8 ( 'red' , 100 ) ;
100100 const expected = PALETTE . red [ 100 ] ;
101101
102102 expect ( color ) . toBe ( expected ) ;
103103 } ) ;
104104
105105 it ( 'darkens the color if shade is greater than what exists within the hue' , ( ) => {
106- const color = getColor ( 'blue' , 900 ) ;
106+ const color = getColorV8 ( 'blue' , 900 ) ;
107107 const expected = darken ( 0.05 , PALETTE . blue [ 800 ] ) ;
108108
109109 expect ( color ) . toBe ( expected ) ;
110110 } ) ;
111111
112112 it ( 'darkens a non-hue color if shade is greater than the default' , ( ) => {
113113 const hex = '#fd5a1e' ;
114- const color = getColor ( hex , DEFAULT_SHADE + 100 ) ;
114+ const color = getColorV8 ( hex , DEFAULT_SHADE + 100 ) ;
115115 const expected = darken ( 0.05 , hex ) ;
116116
117117 expect ( color ) . toBe ( expected ) ;
118118 } ) ;
119119
120120 it ( 'lightens the color if shade is lesser than what what exists within the hue' , ( ) => {
121- const color = getColor ( 'blue' , 0 ) ;
121+ const color = getColorV8 ( 'blue' , 0 ) ;
122122 const expected = lighten ( 0.05 , PALETTE . blue [ 100 ] ) ;
123123
124124 expect ( color ) . toBe ( expected ) ;
125125 } ) ;
126126
127127 it ( 'lightens a non-hue color if shade is greater than the default' , ( ) => {
128128 const hex = '#fd5a1e' ;
129- const color = getColor ( hex , DEFAULT_SHADE - 100 ) ;
129+ const color = getColorV8 ( hex , DEFAULT_SHADE - 100 ) ;
130130 const expected = lighten ( 0.05 , hex ) ;
131131
132132 expect ( color ) . toBe ( expected ) ;
133133 } ) ;
134134
135135 it ( 'is undefined if shade is invalid' , ( ) => {
136- const color = getColor ( 'red' , NaN ) ;
136+ const color = getColorV8 ( 'red' , NaN ) ;
137137
138138 expect ( color ) . toBeUndefined ( ) ;
139139 } ) ;
@@ -158,13 +158,13 @@ describe('_getColor', () => {
158158
159159 it ( 'falls back when hue is off palette' , ( ) => {
160160 const expected = 'blue' ;
161- const color = getColor ( expected , undefined , theme ) ;
161+ const color = getColorV8 ( expected , undefined , theme ) ;
162162
163163 expect ( color ) . toBe ( expected ) ;
164164 } ) ;
165165
166166 it ( 'gets the specified color from the theme' , ( ) => {
167- const color = getColor ( 'test' , 400 , theme ) ;
167+ const color = getColorV8 ( 'test' , 400 , theme ) ;
168168 const expected = theme . palette . test [ 400 ] ;
169169
170170 expect ( color ) . toBe ( expected ) ;
@@ -178,7 +178,7 @@ describe('_getColor', () => {
178178 ( PALETTE as any ) [ DEFAULT_THEME . colors . primaryHue ] [ DEFAULT_SHADE ] ,
179179 transparency
180180 ) ;
181- const color = getColor ( 'primaryHue' , undefined , undefined , transparency ) ;
181+ const color = getColorV8 ( 'primaryHue' , undefined , undefined , transparency ) ;
182182
183183 expect ( color ) . toBe ( expected ) ;
184184 } ) ;
0 commit comments