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

    const emailInput = getByPlaceholderText('Email');

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

    expect(component.form.$$.ctx.$errors).toEqual({});
  });
github mdauner / sveltejs-forms / tests / Form / Form.spec.js View on Github external
expect(component.form.$$.ctx.$errors).toMatchSnapshot();
            expect(component.form.$$.ctx.$touched).toMatchSnapshot();

            done();
          }
        ),
      },
    });

    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
const handleCheckableInput = async (input: HTMLInputElement) => {
        input.checked = !input.checked;
        await fireEvent.input(input);
        await fireEvent.change(input);
    }
github wix-incubator / unidriver / adapters / jsdom-svelte / src / index.ts View on Github external
enterValue: async (value: string) => {
            const el = (await elem()) as HTMLInputElement;
            const { name, type } = el;
            await fireEvent.change(el, {
                target: { name, type, value }
            });
        },
        attr: async (name: string) => {