Skip to content

Commit

Permalink
Update RTL to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverjam committed Sep 24, 2019
1 parent f693fc0 commit cd19c22
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 80 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ It's worth noting that `toEqual` performs a recursive check of all properties on
```js
const dip1 = {
name: "hummus",
flavour: "*****"
flavour: "*****",
};

const dip2 = {
name: "hummus",
flavour: "*****"
flavour: "*****",
};
```

Expand Down Expand Up @@ -112,11 +112,11 @@ We'll be using [React Testing Library](https://testing-library.com/docs/react-te

#### Rendering

We can render our components to jsdom using RTL's [`render`](https://testing-library.com/docs/react-testing-library/api#render) method.
We can render our components to jsdom using RTL's [`render`](https://testing-library.com/docs/@testing-library/react/api#render) method.

```jsx
import React from "react";
import { render } from "react-testing-library";
import { render } from "@testing-library/react";
import Button from "./Button";

test("The button renders", () => {
Expand All @@ -130,7 +130,7 @@ The return value of `render` is an object with [useful methods](https://testing-

```jsx
import React from "react";
import { render } from "react-testing-library";
import { render } from "@testing-library/react";
import Button from "./Button";

test("The button renders", () => {
Expand All @@ -155,7 +155,7 @@ Imagine the `Button` component we're testing changes its text from 'click me' to

```jsx
import React from "react";
import { render, fireEvent } from "react-testing-library";
import { render, fireEvent } from "@testing-library/react";
import Button from "./Button";

test("The button renders", () => {
Expand Down
220 changes: 153 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0",
"@testing-library/react": "^9.1.4",
"jest": "^24.8.0",
"parcel-bundler": "^1.12.3",
"react-testing-library": "^7.0.1"
"parcel-bundler": "^1.12.3"
},
"dependencies": {
"react": "^16.9.0-alpha.0",
Expand Down
4 changes: 2 additions & 2 deletions solution/jadenizer/jadenizer.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render, cleanup, fireEvent } from "react-testing-library";
import { render, cleanup, fireEvent } from "@testing-library/react";
import Jadenizer from "../../workshop/jadenizer/jadenizer.js";

// ensures our document gets cleared out after each test
Expand All @@ -12,7 +12,7 @@ test("Jadenizer component", () => {

const input = getByLabelText("Enter text for Jadenization");
fireEvent.change(input, {
target: { value: `how can mirrors be real if our eyes aren't real` }
target: { value: `how can mirrors be real if our eyes aren't real` },
}); // fire the onChange event with a value

const button = getByText("Jadenize");
Expand Down
4 changes: 2 additions & 2 deletions solution/markdownifier/markdownifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
render,
fireEvent,
cleanup,
waitForElement
} from "react-testing-library";
waitForElement,
} from "@testing-library/react";
import Markdownifier from "../../workshop/markdownifier/markdownifier.js";

// ensures our document gets cleared out after each test
Expand Down
Loading

0 comments on commit cd19c22

Please sign in to comment.