Skip to content

Commit

Permalink
Add color-picker integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
derekblank committed Aug 11, 2023
1 parent 72432f7 commit 20ae378
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/components/src/color-picker/test/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* External dependencies
*/
import { render, fireEvent } from 'test/helpers';

/**
* WordPress dependencies
*/
import { ColorPicker } from '@wordpress/components';

describe( 'color picker', () => {
it( 'selects the correct color', async () => {
const shouldEnableBottomSheetMaxHeight = jest.fn();
const onHandleClosingBottomSheet = jest.fn();

const { getByTestId } = render(
<ColorPicker
shouldEnableBottomSheetMaxHeight={
shouldEnableBottomSheetMaxHeight
}
onHandleClosingBottomSheet={ onHandleClosingBottomSheet }
testID="color-picker"
/>
);

const colorPicker = getByTestId( 'color-picker' );

// Assert label text before tapping color picker
expect( colorPicker.getByText( 'Select a color' ) ).toBeVisible();

// Tap color picker
fireEvent( colorPicker, 'onHuePickerPress', {
hue: 120,
saturation: 12,
value: 50,
} );

// Assert label hex value after tapping color picker
expect( colorPicker.getByText( '#00FF00' ) ).toBeVisible();
} );
} );

0 comments on commit 20ae378

Please sign in to comment.