Skip to content

Commit efe7602

Browse files
committed
fix(readme): simplify the example
1 parent 1451672 commit efe7602

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

README.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,15 @@ import { render } from "redux-testing-library";
2323

2424
import { TodoApp, TodoActions, TodoSelectors } from "./example";
2525

26-
describe("todo app", () => {
27-
describe("when addTodo action is dispatched with a given text as payload", () => {
28-
it("adds a todo item with the given text to the store", async () => {
29-
const { store, waitForStoreChange } = render(<TodoApp.UI />, TodoApp.store);
30-
31-
store.dispatch(TodoActions.addTodo("Do homework!"));
32-
33-
await waitForStoreChange(state => {
34-
expect(TodoSelectors.getTodos(state)).toStrictEqual([
35-
{ id: 0, completed: false, text: "Do homework!" }
36-
]);
37-
});
26+
describe("when addTodo action is dispatched", () => {
27+
it("adds todo item to the store", async () => {
28+
const { store, waitForStoreChange } = render(<TodoApp.UI />, TodoApp.store);
29+
30+
store.dispatch(TodoActions.addTodo("Test your application"));
31+
32+
await waitForStoreChange(state => {
33+
const todos = TodoSelectors.getTodos(state);
34+
expect(todos[0].text).toBe("Test your application");
3835
});
3936
});
4037
});

test/redux-testing-library.test.tsx

+7-10
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@ import * as React from "react";
33
import { render } from "../src/redux-testing-library";
44
import { TodoApp, TodoActions, TodoSelectors } from "./example";
55

6-
describe("todo app", () => {
7-
describe("when addTodo action is dispatched with a given text as payload", () => {
8-
it("adds a todo item with the given text to the store", async () => {
9-
const { store, waitForStoreChange } = render(<TodoApp.UI />, TodoApp.store);
6+
describe("when addTodo action is dispatched", () => {
7+
it("adds todo item to the store", async () => {
8+
const { store, waitForStoreChange } = render(<TodoApp.UI />, TodoApp.store);
109

11-
store.dispatch(TodoActions.addTodo("Do homework!"));
10+
store.dispatch(TodoActions.addTodo("Test your application"));
1211

13-
await waitForStoreChange(state => {
14-
expect(TodoSelectors.getTodos(state)).toStrictEqual([
15-
{ id: 0, completed: false, text: "Do homework!" }
16-
]);
17-
});
12+
await waitForStoreChange(state => {
13+
const todos = TodoSelectors.getTodos(state);
14+
expect(todos[0].text).toBe("Test your application");
1815
});
1916
});
2017
});

0 commit comments

Comments
 (0)