Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(reducers/users/test): add test to handle location change to othe…
Browse files Browse the repository at this point in the history
…r paths except /users

feat(reducers/users/test): add test to handle location change to other
paths except /users

Test «it('should return same state if LOCATION_CHANGE navigates to
/users/:id'» was updated

Test «it(‘should handle LOCATION_CHANGE to not /users path’» was added
  • Loading branch information
Metnew committed Aug 14, 2017
1 parent 707e455 commit dc8849b
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/common/reducers/users/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ const GET_USERS_PENDING = {
const LOCATION_CHANGE_INBOX_ID = {
type: actions.LOCATION_CHANGE,
payload: {
pathname: '/inbox/1'
pathname: '/users/1'
}
}

const LOCATION_CHANGE_TO_OTHER_PATH = {
type: actions.LOCATION_CHANGE,
payload: {
pathname: '/'
}
}

Expand Down Expand Up @@ -66,9 +73,21 @@ describe('USERS REDUCER', () => {
})
})

it('should return same state if LOCATION_CHANGE navigates to inbox/:id route', () => {
expect(reducer(initialState, LOCATION_CHANGE_INBOX_ID)).toEqual(
initialState
it('should return same state if LOCATION_CHANGE navigates to /users/:id', () => {
const customState = {
...initialState,
hello: 'world'
}
expect(reducer(customState, LOCATION_CHANGE_INBOX_ID)).toEqual(
customState
)
})

it('should handle LOCATION_CHANGE to not /users path', () => {
const customState = {
...initialState,
hello: 'world'
}
expect(reducer(customState, LOCATION_CHANGE_TO_OTHER_PATH)).toEqual(initialState)
})
})

0 comments on commit dc8849b

Please sign in to comment.