File tree 2 files changed +16
-22
lines changed
2 files changed +16
-22
lines changed Original file line number Diff line number Diff line change @@ -23,18 +23,15 @@ import { render } from "redux-testing-library";
23
23
24
24
import { TodoApp , TodoActions , TodoSelectors } from " ./example" ;
25
25
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" );
38
35
});
39
36
});
40
37
});
Original file line number Diff line number Diff line change @@ -3,18 +3,15 @@ import * as React from "react";
3
3
import { render } from "../src/redux-testing-library" ;
4
4
import { TodoApp , TodoActions , TodoSelectors } from "./example" ;
5
5
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 ) ;
10
9
11
- store . dispatch ( TodoActions . addTodo ( "Do homework! " ) ) ;
10
+ store . dispatch ( TodoActions . addTodo ( "Test your application " ) ) ;
12
11
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" ) ;
18
15
} ) ;
19
16
} ) ;
20
17
} ) ;
You can’t perform that action at this time.
0 commit comments