-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from sachie/feat/update-redux-structure
Update redux structure to use redux-toolkit.
- Loading branch information
Showing
16 changed files
with
144 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Description | ||
|
||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. | ||
|
||
Fixes # (issue) | ||
|
||
## Type of change | ||
|
||
- [ ] Bug fix | ||
- [ ] New feature | ||
- [ ] Breaking change | ||
|
||
# Checklist: | ||
|
||
- [ ] Tests updated | ||
- [ ] Documentation updated | ||
- [ ] Code comments included | ||
- [ ] Lint passing | ||
- [ ] Tests passing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { Provider } from 'react-redux'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { render, screen } from '@testing-library/react'; | ||
import messages from 'utils/messages'; | ||
import App from './App'; | ||
import store from './store'; | ||
|
||
test('renders title and readme link', () => { | ||
render( | ||
<MemoryRouter> | ||
<App /> | ||
</MemoryRouter>, | ||
<Provider store={store}> | ||
<MemoryRouter> | ||
<App /> | ||
</MemoryRouter> | ||
</Provider>, | ||
); | ||
const titleElement = screen.getByText(messages.common.title); | ||
expect(titleElement).toBeInTheDocument(); | ||
|
||
const linkElement = screen.getByText(messages.mainPage.readme); | ||
expect(linkElement).toBeInTheDocument(); | ||
expect(screen.getByText(messages.common.title)).toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
const initialState = { | ||
value: 0, | ||
}; | ||
|
||
export const homeSlice = createSlice({ | ||
name: 'home', | ||
initialState, | ||
reducers: { | ||
increment: state => { | ||
state.value += 1; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { increment } = homeSlice.actions; | ||
|
||
export default homeSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Provider } from 'react-redux'; | ||
import { render, screen } from '@testing-library/react'; | ||
import store from 'store'; | ||
import messages from 'utils/messages'; | ||
import Home from './index'; | ||
|
||
test('renders title and readme link', () => { | ||
render( | ||
<Provider store={store}> | ||
<Home /> | ||
</Provider>, | ||
); | ||
|
||
expect(screen.getByText(messages.common.title)).toBeInTheDocument(); | ||
expect(screen.getByText(messages.mainPage.getStarted)).toBeInTheDocument(); | ||
expect(screen.getByText(messages.mainPage.visitThe, { exact: false })).toBeInTheDocument(); | ||
expect(screen.getByText(messages.mainPage.readme)).toBeInTheDocument(); | ||
expect(screen.getByText(messages.mainPage.moreInfo, { exact: false })).toBeInTheDocument(); | ||
expect(screen.getByText(messages.mainPage.moreInfo, { exact: false })).toBeInTheDocument(); | ||
|
||
const countElement = screen.getByTestId('count'); | ||
const logoElement = screen.getByAltText('Logo'); | ||
expect(countElement).toHaveTextContent('0'); | ||
logoElement.click(); | ||
expect(countElement).toHaveTextContent('1'); | ||
logoElement.click(); | ||
expect(countElement).toHaveTextContent('2'); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import reducer from './reducer'; | ||
import reducer, { increment } from './homeSlice'; | ||
|
||
describe('home reducer', () => { | ||
it('should return the initial state', () => { | ||
expect(reducer(undefined, {})).toEqual({}); | ||
}); | ||
const initialState = { | ||
value: 0, | ||
}; | ||
|
||
test('should return the initial state', () => { | ||
expect(reducer(undefined, {})).toEqual(initialState); | ||
}); | ||
|
||
it('should handle a test action', () => { | ||
expect( | ||
reducer([], { | ||
type: 'home/some/action', | ||
}), | ||
).toEqual({}); | ||
test('should handle an increment', () => { | ||
expect(reducer(initialState, increment())).toEqual({ | ||
value: 1, | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import homeReducer from 'pages/Home/homeSlice'; | ||
|
||
export default configureStore({ | ||
reducer: { | ||
home: homeReducer, | ||
}, | ||
devTools: process.env.NODE_ENV !== 'production', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters