mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into turn-on-strict
This commit is contained in:
commit
baac515276
@ -48,4 +48,24 @@ describe("<Switch/>", () => {
|
|||||||
|
|
||||||
expect(onClick).not.toHaveBeenCalled();
|
expect(onClick).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("returns true checked attribute in a onChange callback", () => {
|
||||||
|
const onClick = jest.fn();
|
||||||
|
const { getByTestId } = render(<Switch onChange={onClick} checked={true}/>);
|
||||||
|
const switcher = getByTestId("switch");
|
||||||
|
|
||||||
|
fireEvent.click(switcher);
|
||||||
|
|
||||||
|
expect(onClick).toHaveBeenCalledWith(false, expect.any(Object));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns false checked attribute in a onChange callback", () => {
|
||||||
|
const onClick = jest.fn();
|
||||||
|
const { getByTestId } = render(<Switch onChange={onClick}/>);
|
||||||
|
const switcher = getByTestId("switch");
|
||||||
|
|
||||||
|
fireEvent.click(switcher);
|
||||||
|
|
||||||
|
expect(onClick).toHaveBeenCalledWith(true, expect.any(Object));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export function Switch({ children, disabled, onChange, ...props }: SwitchProps)
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
role="switch"
|
role="switch"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onChange={(event) => onChange?.(props.checked ?? event.target.checked, event)}
|
onChange={(event) => onChange?.(event.target.checked, event)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user