From efe7602df80e6ce1d7a33069b11859035c3c0659 Mon Sep 17 00:00:00 2001 From: Jan Brockmeyer Date: Tue, 28 May 2019 00:20:57 +0200 Subject: [PATCH] fix(readme): simplify the example --- README.md | 21 +++++++++------------ test/redux-testing-library.test.tsx | 17 +++++++---------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index a11079c..86381db 100644 --- a/README.md +++ b/README.md @@ -23,18 +23,15 @@ import { render } from "redux-testing-library"; import { TodoApp, TodoActions, TodoSelectors } from "./example"; -describe("todo app", () => { - describe("when addTodo action is dispatched with a given text as payload", () => { - it("adds a todo item with the given text to the store", async () => { - const { store, waitForStoreChange } = render(, TodoApp.store); - - store.dispatch(TodoActions.addTodo("Do homework!")); - - await waitForStoreChange(state => { - expect(TodoSelectors.getTodos(state)).toStrictEqual([ - { id: 0, completed: false, text: "Do homework!" } - ]); - }); +describe("when addTodo action is dispatched", () => { + it("adds todo item to the store", async () => { + const { store, waitForStoreChange } = render(, TodoApp.store); + + store.dispatch(TodoActions.addTodo("Test your application")); + + await waitForStoreChange(state => { + const todos = TodoSelectors.getTodos(state); + expect(todos[0].text).toBe("Test your application"); }); }); }); diff --git a/test/redux-testing-library.test.tsx b/test/redux-testing-library.test.tsx index cc9a1ba..763c48c 100644 --- a/test/redux-testing-library.test.tsx +++ b/test/redux-testing-library.test.tsx @@ -3,18 +3,15 @@ import * as React from "react"; import { render } from "../src/redux-testing-library"; import { TodoApp, TodoActions, TodoSelectors } from "./example"; -describe("todo app", () => { - describe("when addTodo action is dispatched with a given text as payload", () => { - it("adds a todo item with the given text to the store", async () => { - const { store, waitForStoreChange } = render(, TodoApp.store); +describe("when addTodo action is dispatched", () => { + it("adds todo item to the store", async () => { + const { store, waitForStoreChange } = render(, TodoApp.store); - store.dispatch(TodoActions.addTodo("Do homework!")); + store.dispatch(TodoActions.addTodo("Test your application")); - await waitForStoreChange(state => { - expect(TodoSelectors.getTodos(state)).toStrictEqual([ - { id: 0, completed: false, text: "Do homework!" } - ]); - }); + await waitForStoreChange(state => { + const todos = TodoSelectors.getTodos(state); + expect(todos[0].text).toBe("Test your application"); }); }); });