@@ -21,9 +21,9 @@ const Counter = ({ dispatch, count }) => {
2121 < div>
2222 < h2> Counter< / h2>
2323 < div>
24- < button onClick= {this . decrement }> - < / button>
24+ < button onClick= {decrement}> - < / button>
2525 < span data- testid= " count-value" > {count}< / span>
26- < button onClick= {this . increment }> + < / button>
26+ < button onClick= {increment}> + < / button>
2727 < / div>
2828 < / div>
2929 )
@@ -67,11 +67,12 @@ import React from 'react'
6767import { render as rtlRender } from ' @testing-library/react'
6868import { createStore } from ' redux'
6969import { Provider } from ' react-redux'
70+ import { initialState as reducerInitialState , reducer } from ' ./reducer'
7071
7172function render (
7273 ui ,
7374 {
74- initialState,
75+ initialState = reducerInitialState ,
7576 store = createStore (reducer, initialState),
7677 ... renderOptions
7778 } = {}
@@ -93,24 +94,21 @@ export { render }
9394// counter.test.js
9495import React from ' react'
9596import { createStore } from ' redux'
96- import { Provider } from ' react-redux'
97- import { } from ' @testing-library/react'
9897// We're using our own custom render function and not RTL's render
9998// our custom utils also re-export everything from RTL
10099// so we can import fireEvent and screen here as well
101- import { render , fireEvent , screen } from ' ./test-utils.js
100+ import { render , fireEvent , screen } from ' ./test-utils'
102101import ' @testing-library/jest-dom/extend-expect'
103- import { initialState, reducer } from ' ./reducer.js'
104- import Counter from ' ./counter.js'
102+ import Counter from ' ./counter'
105103
106104test (' can render with redux with defaults' , () => {
107- renderWithRedux (<Counter />)
105+ render (< Counter / > )
108106 fireEvent .click (screen .getByText (' +' ))
109107 expect (screen .getByTestId (' count-value' )).toHaveTextContent (' 1' )
110108})
111109
112110test (' can render with redux with custom initial state' , () => {
113- renderWithRedux (<Counter />, {
111+ render (< Counter / > , {
114112 initialState: { count: 3 },
115113 })
116114 fireEvent .click (screen .getByText (' -' ))
@@ -120,7 +118,7 @@ test('can render with redux with custom initial state', () => {
120118test (' can render with redux with custom store' , () => {
121119 // this is a silly store that can never be changed
122120 const store = createStore (() => ({ count: 1000 }))
123- renderWithRedux (<Counter />, {
121+ render (< Counter / > , {
124122 store,
125123 })
126124 fireEvent .click (screen .getByText (' +' ))
0 commit comments