How to use the @testing-library/svelte.fireEvent.click function in @testing-library/svelte

To help you get started, we’ve selected a few @testing-library/svelte examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mdauner / sveltejs-forms / tests / Form / Form.spec.js View on Github external
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);
  });
github shipshapecode / shepherd / test / unit / components / shepherd-header.spec.js View on Github external
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);
  });
});
github mdauner / sveltejs-forms / tests / Form / Form.spec.js View on Github external
),
      },
    });

    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);
  });
github mdauner / sveltejs-forms / tests / Form / Form.spec.js View on Github external
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);
  });
github wix-incubator / unidriver / adapters / jsdom-svelte / src / index.ts View on Github external
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: {