Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
Bug/136 unset reason when request isn't rejected anymore (#297)
Browse files Browse the repository at this point in the history
* reset status and reason in request reducer

* add required tests to request reducer

* 6.2.3-0

* update flow confing in circle CI
  • Loading branch information
HashemKhalifa authored and frontendphil committed Mar 29, 2019
1 parent fe6cf53 commit 970e990
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:

- *restore_deps

- run: yarn flow
- run: yarn flow --max-workers 1

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signavio/kraken",
"version": "6.2.2",
"version": "6.2.3-0",
"description": "Load API entities",
"repository": "git@github.com:signavio/kraken.git",
"main": "lib/index.js",
Expand Down
6 changes: 5 additions & 1 deletion src/reducers/requestsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const requestsReducer = (state: RequestsState, action: Action) => {
refresh:
payload.refresh !== undefined ? payload.refresh : request.refresh,
value: needsRefresh ? undefined : request.value,
reason: null,
status: null,
},
}
case actionTypes.REQUEST_START:
Expand All @@ -52,8 +54,10 @@ const requestsReducer = (state: RequestsState, action: Action) => {
pending: false,
fulfilled: true,
rejected: false,
responseHeaders: payload.responseHeaders,
value: payload.value,
responseHeaders: payload.responseHeaders,
reason: null,
status: payload.status,
},
}
case actionTypes.FETCH_FAILURE:
Expand Down
7 changes: 7 additions & 0 deletions test/specs/reducers/requestReducer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ describe('requestReducer', () => {
'requestParams',
requestParams
)
expect(newState[newRequestId]).to.have.property('reason', null)
expect(newState[newRequestId]).to.have.property('status', null)
})

it('should set pending and outstanding flags', () => {
Expand Down Expand Up @@ -152,6 +154,7 @@ describe('requestReducer', () => {
requestId,
entityType: types.USER,
query,
status: 200,
value: result,
})
)
Expand All @@ -161,6 +164,8 @@ describe('requestReducer', () => {
expect(newState[requestId]).to.have.property('pending', false)
expect(newState[requestId]).to.have.property('fulfilled', true)
expect(newState[requestId]).to.have.property('rejected', false)
expect(newState[requestId]).to.have.property('reason', null)
expect(newState[requestId]).to.have.property('status', 200)
})

it('should set the value', () => {
Expand Down Expand Up @@ -258,11 +263,13 @@ describe('requestReducer', () => {
entityType: types.USER,
requestId,
error,
status: 502,
})
)

expect(newState).to.have.property(requestId)
expect(newState[requestId]).to.have.property('reason', error)
expect(newState[requestId]).to.have.property('status', 502)
})
})
})

0 comments on commit 970e990

Please sign in to comment.