Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('click on submit button dispatches submit event and sets isSubmitting to true', async () => {
const { component, getByText } = await render(App, {
props: { onSubmit: jest.fn() },
});
const signInButton = getByText('Sign in');
expect(component.form.$$.ctx.$isSubmitting).toBe(false);
expect(signInButton).not.toHaveAttribute('disabled');
await fireEvent.click(signInButton);
await wait();
expect(component.onSubmit).toHaveBeenCalledTimes(1);
expect(signInButton).toHaveAttribute('disabled');
expect(component.form.$$.ctx.$isSubmitting).toBe(true);
});
it('cancel icon cancels the tour', async() => {
const tour = new Tour();
const step = new Step(tour, {
cancelIcon: {
enabled: true
}
});
const stepCancelSpy = spy(step, 'cancel');
const { container } = render(ShepherdHeader, {
props: {
step
}
});
fireEvent.click(container.querySelector('.shepherd-cancel-icon'));
expect(stepCancelSpy.called).toBe(true);
});
});
),
},
});
const emailInput = getByPlaceholderText('Email');
await fireEvent.change(emailInput, {
target: { value: 'test@user.com' },
});
const languageSelect = container.querySelector('select');
await fireEvent.change(languageSelect, {
target: { value: 'svelte' },
});
let osChoice = getByText('macOS');
await fireEvent.click(osChoice);
osChoice = getByText('Windows');
await fireEvent.click(osChoice);
const signInButton = getByText('Sign in');
expect(component.form.$$.ctx.$isSubmitting).toBe(false);
expect(signInButton).not.toHaveAttribute('disabled');
await fireEvent.click(signInButton);
});
const emailInput = getByPlaceholderText('Email');
await fireEvent.change(emailInput, {
target: { value: 'test@user.com' },
});
const languageSelect = container.querySelector('select');
await fireEvent.change(languageSelect, {
target: { value: 'svelte' },
});
let osChoice = getByText('macOS');
await fireEvent.click(osChoice);
osChoice = getByText('Windows');
await fireEvent.click(osChoice);
const signInButton = getByText('Sign in');
expect(component.form.$$.ctx.$isSubmitting).toBe(false);
expect(signInButton).not.toHaveAttribute('disabled');
await fireEvent.click(signInButton);
});
if (elementIsFocusable(el)) {
if (document.activeElement != el) {
if (document.activeElement) {
fireEvent.blur(document.activeElement);
}
if (!el.disabled) {
el.focus();
await fireEvent.focus(el);
}
}
}
await fireEvent.mouseUp(el);
await fireEvent.click(el);
if (isCheckable(el)) {
handleCheckableInput(el as HTMLInputElement);
}
},
mouse: {