1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

fix(service): service related UI issues [EE-4062] (#7943)

This commit is contained in:
Chamhaw 2023-05-25 11:59:32 +08:00 committed by GitHub
parent 93866644c6
commit a2f734051c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 136 additions and 98 deletions

View file

@ -7,6 +7,7 @@ function renderDefault({
checked = false,
label = 'label',
onChange = jest.fn(),
index,
}: Partial<Props> = {}) {
return render(
<SwitchField
@ -14,6 +15,7 @@ function renderDefault({
name={name}
checked={checked}
onChange={onChange}
index={index}
/>
);
}
@ -33,5 +35,17 @@ test('clicking should emit on-change with the opposite value', async () => {
const switchElem = await findByRole('checkbox');
fireEvent.click(switchElem);
expect(onChange).toHaveBeenCalledWith(!checked);
expect(onChange).toHaveBeenCalledWith(!checked, undefined);
});
test('clicking should emit on-change with the opposite value and index', async () => {
const onChange = jest.fn();
const checked = true;
const index = 3;
const { findByRole } = renderDefault({ onChange, checked, index });
const switchElem = await findByRole('checkbox');
fireEvent.click(switchElem);
expect(onChange).toHaveBeenCalledWith(!checked, index);
});