This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fireEvent.change(screen.getByRole("textbox", { name: "Name" }), { | |
target: { value: "Test" }, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const defaultData = { | |
conditionsAccepted: false, | |
confirmPassword: "", | |
email: "", | |
name: "", | |
password: "", | |
}; | |
describe("Form", () => { | |
it("should save correct data on submit", () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const Form = ({ saveData }) => { | |
const [state, setState] = useState({ | |
name: "", | |
email: "", | |
password: "", | |
confirmPassword: "", | |
conditionsAccepted: false, | |
}); | |
const onFieldChange = (event) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render, screen } from "@testing-library/react"; | |
import React from "react"; | |
import { ListPage } from "./ListPage"; | |
describe("ListPage", () => { | |
it("renders without breaking", () => { | |
render(<ListPage />); | |
expect( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ListPage = () => { | |
return ( | |
<div className="text-list__container"> | |
<h1>List of items</h1> | |
<ItemList /> | |
</div> | |
); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { ChangeEvent, FormEvent, useState } from "react"; | |
import "./form.css"; | |
export const Form = () => { | |
const [state, setState] = useState({ | |
name: "", | |
email: "", | |
password: "", | |
confirmPassword: "", | |
conditionsAccepted: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
else if (event.target.type === "number") { | |
value = parseInt(event.target.value, 10); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const Form = () => { | |
const [state, setState] = useState({ | |
name: "", | |
email: "", | |
password: "", | |
confirmPassword: "", | |
conditionsAccepted: false, | |
}); | |
const onFieldChange = (event: any) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input | |
id="name" | |
onChange={(event) => setState({ ...state, name: event.target.value })} | |
/> |