File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
- import { render , cleanup } from '@testing-library/react'
2
+ import { render , cleanup , fireEvent } from '@testing-library/react'
3
3
import Provider from 'muriatic'
4
4
import '@testing-library/jest-dom/extend-expect'
5
5
import TodoList from './index'
@@ -37,3 +37,18 @@ test('should render stored todo values', () => {
37
37
expect ( getAllByTestId ( 'todo-item' ) [ 1 ] ) . toHaveTextContent ( 'boss black' )
38
38
expect ( getAllByTestId ( 'todo-item' ) [ 2 ] ) . toHaveTextContent ( 'caffe latte' )
39
39
} )
40
+
41
+ test ( 'should reflect store value change to render elements' , ( ) => {
42
+ const { getByTestId, getAllByTestId } = render (
43
+ < Provider store = { initialStore } >
44
+ < TodoList path = "/" />
45
+ </ Provider >
46
+ )
47
+
48
+ // delete first todo
49
+ fireEvent . click ( getAllByTestId ( 'delete-todo-btn' ) [ 0 ] )
50
+ expect ( getByTestId ( 'todo-list' ) . children . length ) . toBe ( 2 )
51
+ expect ( Array . isArray ( getAllByTestId ( 'todo-item' ) ) ) . toBe ( true )
52
+ expect ( getAllByTestId ( 'todo-item' ) [ 0 ] ) . toHaveTextContent ( 'boss black' )
53
+ expect ( getAllByTestId ( 'todo-item' ) [ 1 ] ) . toHaveTextContent ( 'caffe latte' )
54
+ } )
You can’t perform that action at this time.
0 commit comments