How to use the @testing-library/svelte.fireEvent.blur 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 / Input / Input.spec.js View on Github external
it('validates on blur if validateOnBlur is true', async () => {
    const schema = yup.object().shape({
      email: yup.string().email(),
    });
    const { component, getByPlaceholderText } = await render(App, {
      props: { schema, validateOnChange: false, validateOnBlur: true },
    });

    const emailInput = getByPlaceholderText('Email');

    await fireEvent.change(emailInput, {
      target: { value: 'invalid value' },
    });
    await fireEvent.blur(emailInput);
    await wait();

    expect(component.form.$$.ctx.$errors).toEqual({
      email: 'email must be a valid email',
    });
  });
github mdauner / sveltejs-forms / tests / Form / Form.spec.js View on Github external
}),
    });
    const {
      container,
      component,
      getByPlaceholderText,
      getByText,
    } = await render(App, {
      props: { schema },
    });
    const emailInput = getByPlaceholderText('Email');

    await fireEvent.change(emailInput, {
      target: { value: 'invalid value' },
    });
    await fireEvent.blur(emailInput);
    await wait(() => {
      expect(getByText('user.email must be a valid email')).toBeInTheDocument();
    });
    expect(component.form.$$.ctx.$errors).toEqual({
      user: { email: 'user.email must be a valid email' },
    });

    expect(container.firstChild).toMatchSnapshot();
  });
github wix-incubator / unidriver / adapters / jsdom-svelte / src / index.ts View on Github external
click: async () => {
            const el = await elem();
            await fireEvent.mouseDown(el);

            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);
            }