Skip to content

Commit cb9f7ec

Browse files
authored
fix: reloadButton refreshes all data in the store (#6)
1 parent b56adf1 commit cb9f7ec

20 files changed

Lines changed: 136 additions & 21 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = {
4545
trailingComma: 'all',
4646
},
4747
],
48+
'react/jsx-curly-brace-presence': 'never', // use '' when passing a strint as a property
4849
'react/jsx-filename-extension': 0, // we do not use *.jsx files
4950
'react/sort-comp': 2,
5051
},

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
2323

2424
* `<TrelloCardIframe />` deprecated, use `<TrelloCardUi />` instead now
2525

26+
### Fixed
27+
28+
* reloadButton refreshes all data in the store
29+
2630
## 2018/04/22 0.0.1
2731

2832
### Added

src/actions/__test__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from '../'
1616

1717
describe('actions/index', () => {
18-
it('should export the expected actions', () => {
18+
test('should export the expected actions', () => {
1919
expect({ app, boards, lists, cards, members, user }).toMatchObject({
2020
app: appActions,
2121
boards: boardActions,

src/actions/boards/__test__/index.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import configureMockStore from 'redux-mock-store'
22
import thunk from 'redux-thunk'
3-
import { actions, addBoardEstimations, receiveBoards, requestBoards } from '../'
3+
import { actions, addBoardEstimations, receiveBoards, requestBoards, resetBoards } from '../'
44

55
// some static mocks
66
import {
@@ -13,6 +13,7 @@ jest.mock('../../../data/trello')
1313

1414
describe('actions/board', () => {
1515
const expectedActions = {
16+
RESET_BOARDS: 'RESET_BOARDS',
1617
REQUEST: 'REQUEST_BOARDS',
1718
RECEIVE: 'RECEIVE_BOARDS',
1819
ADD_BOARD_ESTIMATION: 'ADD_BOARD_ESTIMATION',
@@ -57,7 +58,7 @@ describe('actions/board:async actions', () => {
5758
jest.unmock('../../../data/trello')
5859
})
5960

60-
it('creates RECEIVE when fetching boards has been done', async () => {
61+
test('dispatches RECEIVE when fetching boards has been done', async () => {
6162
// payload is set in setup-jest.js (config mock)
6263
const expectedActions = [
6364
{ type: actions.REQUEST },
@@ -76,4 +77,11 @@ describe('actions/board:async actions', () => {
7677
await store.dispatch(requestBoards())
7778
expect(store.getActions()).toEqual(expectedActions)
7879
})
80+
81+
test('resetBoards should dispatch correct actions', async () => {
82+
const store = mockStore({})
83+
await store.dispatch(resetBoards())
84+
const expectedActions = [{ type: actions.RESET_BOARDS }, { type: actions.REQUEST }]
85+
expect(store.getActions()).toEqual(expectedActions)
86+
})
7987
})

src/actions/boards/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Config from '../../../config/config'
33
import { getMeBoards } from '../../data/trello'
44

55
const actions = {
6+
RESET_BOARDS: 'RESET_BOARDS',
67
REQUEST: 'REQUEST_BOARDS',
78
RECEIVE: 'RECEIVE_BOARDS',
89
ADD_BOARD_ESTIMATION: 'ADD_BOARD_ESTIMATION',
@@ -41,4 +42,11 @@ const requestBoards = () => async dispatch => {
4142
}
4243
}
4344

44-
export { actions, addBoardEstimations, requestBoards, receiveBoards }
45+
const resetAllBoards = () => ({ type: actions.RESET_BOARDS })
46+
47+
const resetBoards = () => dispatch => {
48+
dispatch(resetAllBoards())
49+
dispatch(requestBoards())
50+
}
51+
52+
export { actions, addBoardEstimations, requestBoards, receiveBoards, resetBoards }

src/actions/cards/__test__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('actions/cards:async actions', () => {
3434
jest.unmock('../../../data/trello')
3535
})
3636

37-
it('creates RECEIVE when fetching cards has been done', async () => {
37+
test('creates RECEIVE when fetching cards has been done', async () => {
3838
const list = {
3939
id: 'list-123',
4040
}

src/actions/lists/__test__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('actions/cards:async actions', () => {
3434
jest.unmock('../../../data/trello')
3535
})
3636

37-
it('creates RECEIVE when fetching cards has been done', async () => {
37+
test('creates RECEIVE when fetching cards has been done', async () => {
3838
const exampleBoard = {
3939
id: 'board-1',
4040
}

src/actions/members/__test__/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('actions/members:async actions', () => {
3232
jest.unmock('../../../data/trello')
3333
})
3434

35-
it('dispatches ADD_MEMBERS_ESTIMATION when adding and calculating the estimations has been done', async () => {
35+
test('dispatches ADD_MEMBERS_ESTIMATION when adding and calculating the estimations has been done', async () => {
3636
const expectedActions = [
3737
{
3838
payload: {
@@ -53,7 +53,7 @@ describe('actions/members:async actions', () => {
5353
expect(store.getActions()).toEqual(expectedActions)
5454
})
5555

56-
it('dispatches RECEIVE_MEMBERS when fetching members has been done', async () => {
56+
test('dispatches RECEIVE_MEMBERS when fetching members has been done', async () => {
5757
const expectedActions = [
5858
{ type: actions.REQUEST_MEMBERS },
5959
{

src/components/main-app/__tests__/__snapshots__/component.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exports[`Component/MainApp should render without throwing an error 1`] = `
2525
</WithStyles(Button)>
2626
<WithStyles(Button)
2727
className="MainApp-button-2"
28-
id="doRefreshButton"
28+
id="doResetButton"
2929
onClick={[Function]}
3030
variant="raised"
3131
>

src/components/main-app/__tests__/component.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ describe('Component/MainApp', () => {
2626
isLoading: false,
2727
isMembersLoading: false,
2828
loadBoards: jest.fn(),
29+
reloadBoards: jest.fn(),
2930
loadPreferredMembers: jest.fn(),
3031
}
3132

3233
beforeEach(() => {
3334
props.authorize.mockReset()
3435
props.doTogglePreferred.mockReset()
3536
props.loadBoards.mockReset()
37+
props.reloadBoards.mockReset()
3638
props.loadPreferredMembers.mockReset()
3739
})
3840

@@ -90,10 +92,11 @@ describe('Component/MainApp', () => {
9092
expect(props.doTogglePreferred).toHaveBeenCalledWith(false)
9193
})
9294

93-
test('should invoke loadBoards when Toggle Refresh Boards Button was clicked', () => {
95+
test('should invoke resetBoards when Toggle Refresh Boards Button was clicked', () => {
9496
const wrapper = shallow(<MainApp {...props} />).dive()
95-
wrapper.find('#doRefreshButton').simulate('click')
97+
wrapper.find('#doResetButton').simulate('click')
9698

97-
expect(props.loadBoards).toHaveBeenCalledTimes(1)
99+
expect(props.reloadBoards).toHaveBeenCalledTimes(1)
100+
expect(props.loadPreferredMembers).toHaveBeenCalledTimes(1)
98101
})
99102
})

0 commit comments

Comments
 (0)