Created
June 6, 2019 17:33
-
-
Save ivanbtrujillo/aecdf9cd9dab29171b6d1dabebe55377 to your computer and use it in GitHub Desktop.
react-testing-library-article-6
This file contains hidden or 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 from "react"; | |
import { render, cleanup, fireEvent } from "@testing-library/react"; | |
import Sum from "./Sum"; | |
import "jest-dom/extend-expect"; | |
describe("Sum", () => { | |
it('should sum value1 and value2 and show the result', () => { | |
const { getByTestId } = render(<Sum />); | |
const firstInput= getByTestId("value1"); | |
fireEvent.change(firstInput, { target: { value: 1 } } ); | |
const secondInput= getByTestId("value2"); | |
fireEvent.change(secondInput, { target: { value: 1 } } ); | |
const sumBtn = getByTestId("sum-button"); | |
fireEvent.click(sumBtn); | |
const result = getByTestId("result-txt"); | |
expect(result).toHaveTextContent(2); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment