From 7c18472e4aed38745c8070e913072226872f9dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Go=C5=82as?= Date: Mon, 13 May 2024 17:25:28 +0200 Subject: [PATCH] feat: TET-901 remove onChange --- .../SelectablePill/SelectablePill.props.ts | 1 - .../SelectablePill/SelectablePill.test.tsx | 26 +------------------ .../SelectablePill/SelectablePill.tsx | 10 +------ src/docs-components/SelectablePillDocs.tsx | 21 ++++++++++----- 4 files changed, 17 insertions(+), 41 deletions(-) diff --git a/src/components/SelectablePill/SelectablePill.props.ts b/src/components/SelectablePill/SelectablePill.props.ts index 402ca1d5..59b95532 100644 --- a/src/components/SelectablePill/SelectablePill.props.ts +++ b/src/components/SelectablePill/SelectablePill.props.ts @@ -14,7 +14,6 @@ export type SelectablePillProps = { tabIndex?: number; custom?: SelectablePillConfig; beforeComponent?: BeforeComponentProps; - onChange?: (state: boolean) => void; } & Omit, 'color'>; type BeforeComponentProps = diff --git a/src/components/SelectablePill/SelectablePill.test.tsx b/src/components/SelectablePill/SelectablePill.test.tsx index 1b743844..e876830c 100644 --- a/src/components/SelectablePill/SelectablePill.test.tsx +++ b/src/components/SelectablePill/SelectablePill.test.tsx @@ -1,8 +1,6 @@ -import { vi } from 'vitest'; - import { SelectablePill } from './SelectablePill'; import { SelectablePillState } from './SelectablePillState.type'; -import { render, screen, fireEvent } from '../../tests/render'; +import { render, screen } from '../../tests/render'; describe('SelectablePill', () => { const states: SelectablePillState[] = ['default', 'disabled']; @@ -98,28 +96,6 @@ describe('SelectablePill', () => { selected.forEach((isSelected) => { describe(`isSelected ${isSelected}`, () => { - it('should handle onChange properly when clicked', () => { - const onChangeMock = vi.fn(); - render( - , - ); - - const pill = screen.getByTestId(pillPointer); - expect(pill).toBeInTheDocument(); - fireEvent.click(pill); - if (state !== 'disabled') { - expect(onChangeMock).toHaveBeenCalled(); - expect(onChangeMock).toBeCalledWith(!isSelected); - } else { - expect(onChangeMock).not.toHaveBeenCalled(); - } - }); - it('should correctly render the checkmark', () => { render( = ({ text, prefix, custom, - onChange, ...rest }) => { const styles = useMemo( @@ -54,17 +53,10 @@ export const SelectablePill: FC = ({ [beforeComponent], ); - const handleOnClick: MouseEventHandler = useCallback(() => { - if (state !== 'disabled') { - onChange?.(!isSelected); - } - }, [onChange, state, isSelected]); - return ( ( {appearances.map((appearance) => ( ( {selected.map((select) => ( - + Selected: {String(select)} @@ -88,8 +96,9 @@ export const SelectablePillDocs: FC = () => ( gap="$dimension-300" py="$dimension-500" > - {props.map((prop) => ( + {props.map(({ id, ...prop }) => (