@@ -22,6 +22,8 @@ import { ColorPicker, ColorPickerProps } from './color_picker';
2222import { mount } from 'enzyme' ;
2323import { ReactWrapper } from 'enzyme' ;
2424import { EuiColorPicker , EuiIconTip } from '@elastic/eui' ;
25+ // @ts -ignore
26+ import { findTestSubject } from '@elastic/eui/lib/test' ;
2527
2628describe ( 'ColorPicker' , ( ) => {
2729 const defaultProps : ColorPickerProps = {
@@ -42,6 +44,22 @@ describe('ColorPicker', () => {
4244 expect ( component . find ( '.tvbColorPicker__clear' ) . length ) . toBe ( 0 ) ;
4345 } ) ;
4446
47+ it ( 'should render the correct value to the input text if the prop value is hex' , ( ) => {
48+ const props = { ...defaultProps , value : '#68BC00' } ;
49+ component = mount ( < ColorPicker { ...props } /> ) ;
50+ component . find ( '.tvbColorPicker button' ) . simulate ( 'click' ) ;
51+ const input = findTestSubject ( component , 'topColorPickerInput' ) ;
52+ expect ( input . props ( ) . value ) . toBe ( '#68BC00' ) ;
53+ } ) ;
54+
55+ it ( 'should render the correct value to the input text if the prop value is rgba' , ( ) => {
56+ const props = { ...defaultProps , value : 'rgba(85,66,177,1)' } ;
57+ component = mount ( < ColorPicker { ...props } /> ) ;
58+ component . find ( '.tvbColorPicker button' ) . simulate ( 'click' ) ;
59+ const input = findTestSubject ( component , 'topColorPickerInput' ) ;
60+ expect ( input . props ( ) . value ) . toBe ( '85,66,177,1' ) ;
61+ } ) ;
62+
4563 it ( 'should render the correct aria label to the color swatch button' , ( ) => {
4664 const props = { ...defaultProps , value : 'rgba(85,66,177,0.59)' } ;
4765 component = mount ( < ColorPicker { ...props } /> ) ;
0 commit comments