Skip to content

Instantly share code, notes, and snippets.

fireEvent.change(screen.getByRole("textbox", { name: "Name" }), {
target: { value: "Test" },
});
const defaultData = {
conditionsAccepted: false,
confirmPassword: "",
email: "",
name: "",
password: "",
};
describe("Form", () => {
it("should save correct data on submit", () => {
export const Form = ({ saveData }) => {
const [state, setState] = useState({
name: "",
email: "",
password: "",
confirmPassword: "",
conditionsAccepted: false,
});
const onFieldChange = (event) => {
import { render, screen } from "@testing-library/react";
import React from "react";
import { ListPage } from "./ListPage";
describe("ListPage", () => {
it("renders without breaking", () => {
render(<ListPage />);
expect(
import { render } from '@testing-library/react';
import React from 'react';
import { ListPage } from './ListPage';
describe('ListPage', () => {
it('renders without breaking', () => {
expect(() => render(<ListPage />)).not.toThrow();
});
});
export const ListPage = () => {
return (
<div className="text-list__container">
<h1>List of items</h1>
<ItemList />
</div>
);
};
import React, { ChangeEvent, FormEvent, useState } from "react";
import "./form.css";
export const Form = () => {
const [state, setState] = useState({
name: "",
email: "",
password: "",
confirmPassword: "",
conditionsAccepted: false,
else if (event.target.type === "number") {
value = parseInt(event.target.value, 10);
}
export const Form = () => {
const [state, setState] = useState({
name: "",
email: "",
password: "",
confirmPassword: "",
conditionsAccepted: false,
});
const onFieldChange = (event: any) => {
<input
id="name"
onChange={(event) => setState({ ...state, name: event.target.value })}
/>