Skip to content

Commit

Permalink
test: add unit test
Browse files Browse the repository at this point in the history
(cherry picked from commit 2ef2af4)
  • Loading branch information
Wxh16144 committed Oct 31, 2023
1 parent 61593ed commit f88d3a8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions components/color-picker/__tests__/index.test.tsx
Expand Up @@ -225,6 +225,39 @@ describe('ColorPicker', () => {
expect(handleColorChange).toHaveBeenCalledTimes(2);
});

describe('preset collapsed', () => {
const recommendedPreset = {
label: 'Recommended',
colors: ['#f00', '#0f0', '#00f'],
};

const selector = '.ant-color-picker-presets .ant-collapse-item.ant-collapse-item-active';

it('Should default collapsed work', async () => {
const { container } = render(<ColorPicker open presets={[recommendedPreset]} />);

expect(container.querySelectorAll(selector)).toHaveLength(1);
});

it('Should collapsed work', async () => {
const { container } = render(
<ColorPicker
open
presets={[
recommendedPreset,
{
label: 'Recent',
colors: ['#f00d', '#0f0d', '#00fd'],
collapsed: true,
},
]}
/>,
);

expect(container.querySelectorAll(selector)).toHaveLength(1);
});
});

it('Should format change work', async () => {
const { container } = render(<ColorPicker />);
fireEvent.click(container.querySelector('.ant-color-picker-trigger')!);
Expand Down

0 comments on commit f88d3a8

Please sign in to comment.