From 8e70c0c26865817359ca90ea04e4e4b32b5cb497 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Tue, 7 Apr 2020 09:51:18 +0300 Subject: [PATCH 1/6] Fix: Remove the unnecessary empty import from React-Redux example --- docs/example-react-redux.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/example-react-redux.md b/docs/example-react-redux.md index c759ec3ae..cf378177e 100644 --- a/docs/example-react-redux.md +++ b/docs/example-react-redux.md @@ -94,7 +94,6 @@ export { render } import React from 'react' import { createStore } from 'redux' import { Provider } from 'react-redux' -import { } from '@testing-library/react' // We're using our own custom render function and not RTL's render // our custom utils also re-export everything from RTL // so we can import fireEvent and screen here as well From 84afd3febd425c6c7e4584b3fd0e89e7fd4adb15 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Tue, 7 Apr 2020 09:54:23 +0300 Subject: [PATCH 2/6] Use the render function isntead of renderWithRedux as used to --- docs/example-react-redux.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/example-react-redux.md b/docs/example-react-redux.md index cf378177e..1a22e9b5a 100644 --- a/docs/example-react-redux.md +++ b/docs/example-react-redux.md @@ -103,13 +103,13 @@ import { initialState, reducer } from './reducer.js' import Counter from './counter.js' test('can render with redux with defaults', () => { - renderWithRedux() + render() fireEvent.click(screen.getByText('+')) expect(screen.getByTestId('count-value')).toHaveTextContent('1') }) test('can render with redux with custom initial state', () => { - renderWithRedux(, { + render(, { initialState: { count: 3 }, }) fireEvent.click(screen.getByText('-')) @@ -119,7 +119,7 @@ test('can render with redux with custom initial state', () => { test('can render with redux with custom store', () => { // this is a silly store that can never be changed const store = createStore(() => ({ count: 1000 })) - renderWithRedux(, { + render(, { store, }) fireEvent.click(screen.getByText('+')) From 27a43773324b5aff659b81b076136ded1a0b60f6 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Tue, 7 Apr 2020 10:03:12 +0300 Subject: [PATCH 3/6] Remove unnecessary Provider import --- docs/example-react-redux.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/example-react-redux.md b/docs/example-react-redux.md index 1a22e9b5a..a1f66490a 100644 --- a/docs/example-react-redux.md +++ b/docs/example-react-redux.md @@ -93,7 +93,6 @@ export { render } // counter.test.js import React from 'react' import { createStore } from 'redux' -import { Provider } from 'react-redux' // We're using our own custom render function and not RTL's render // our custom utils also re-export everything from RTL // so we can import fireEvent and screen here as well From 9b4e87c1651aa2095c4dec76ad5032330365ad62 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Tue, 7 Apr 2020 10:11:22 +0300 Subject: [PATCH 4/6] Import the reducer on the correct place --- docs/example-react-redux.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/example-react-redux.md b/docs/example-react-redux.md index a1f66490a..d3701ba73 100644 --- a/docs/example-react-redux.md +++ b/docs/example-react-redux.md @@ -67,6 +67,7 @@ import React from 'react' import { render as rtlRender } from '@testing-library/react' import { createStore } from 'redux' import { Provider } from 'react-redux' +import { initialState, reducer } from './reducer' function render( ui, @@ -96,10 +97,9 @@ import { createStore } from 'redux' // We're using our own custom render function and not RTL's render // our custom utils also re-export everything from RTL // so we can import fireEvent and screen here as well -import { render, fireEvent, screen } from './test-utils.js +import { render, fireEvent, screen } from './test-utils' import '@testing-library/jest-dom/extend-expect' -import { initialState, reducer } from './reducer.js' -import Counter from './counter.js' +import Counter from './counter' test('can render with redux with defaults', () => { render() From cdfafdb423b9168dc7ec7be5155a2bd52f5d1e8f Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Tue, 7 Apr 2020 10:12:58 +0300 Subject: [PATCH 5/6] Fix initialState --- docs/example-react-redux.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/example-react-redux.md b/docs/example-react-redux.md index d3701ba73..c76744578 100644 --- a/docs/example-react-redux.md +++ b/docs/example-react-redux.md @@ -67,12 +67,12 @@ import React from 'react' import { render as rtlRender } from '@testing-library/react' import { createStore } from 'redux' import { Provider } from 'react-redux' -import { initialState, reducer } from './reducer' +import { initialState as reducerInitialState, reducer } from './reducer' function render( ui, { - initialState, + initialState = reducerInitialState, store = createStore(reducer, initialState), ...renderOptions } = {} From fb009d2e59f6a5ca9011f19351d1534fb046bef6 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Tue, 7 Apr 2020 10:24:22 +0300 Subject: [PATCH 6/6] Remove the this from the functional component --- docs/example-react-redux.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/example-react-redux.md b/docs/example-react-redux.md index c76744578..bd93e6caf 100644 --- a/docs/example-react-redux.md +++ b/docs/example-react-redux.md @@ -21,9 +21,9 @@ const Counter = ({ dispatch, count }) => {

Counter

- + {count} - +
)