-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support redirect to previous location after login, test
- Loading branch information
1 parent
22fa1a1
commit 81bb42d
Showing
15 changed files
with
91 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SET_LAST_LOCATION } from '../types' | ||
|
||
export let setLastLocation = props => dispatch => { | ||
dispatch({ type: SET_LAST_LOCATION, payload: props.location.pathname }) | ||
} |
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
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 |
---|---|---|
|
@@ -3,5 +3,6 @@ export default { | |
loggedInUser: {}, | ||
signedUpUser: {}, | ||
projects: [], | ||
error: [] | ||
error: [], | ||
lastLocation: '' | ||
} |
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,13 @@ | ||
import { SET_LAST_LOCATION } from '../types' | ||
import initialState from './initialState' | ||
|
||
const lastLocationReducer = (state = initialState.lastLocation, action) => { | ||
switch (action.type) { | ||
case SET_LAST_LOCATION: | ||
return action.payload | ||
default: | ||
return state | ||
} | ||
} | ||
|
||
export default lastLocationReducer |
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,20 @@ | ||
import thunk from 'redux-thunk' | ||
import configureMockStore from 'redux-mock-store' | ||
import { SET_LAST_LOCATION } from '../../types' | ||
import { setLastLocation } from '../../actions/setLastLocationAction' | ||
|
||
const middlewares = [thunk] | ||
const mockStore = configureMockStore(middlewares) | ||
let store | ||
|
||
describe('setLastLocation action', () => { | ||
beforeEach(() => { | ||
store = mockStore({}) | ||
}) | ||
|
||
it('sets last location to /users', () => { | ||
let props = { location: { pathname: '/users' } } | ||
store.dispatch(setLastLocation(props)) | ||
expect(store.getActions()).toEqual([{ type: SET_LAST_LOCATION, payload: '/users' }]) | ||
}) | ||
}) |
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,17 @@ | ||
import lastLocationReducer from '../../reducers/lastLocationReducer' | ||
import { SET_LAST_LOCATION } from '../../types' | ||
|
||
describe('reduces a user', () => { | ||
it('defaults to empty projects if none are passed in', () => { | ||
expect(lastLocationReducer(undefined, {})).toEqual('') | ||
}) | ||
|
||
it('reduces the signed in user', () => { | ||
expect( | ||
lastLocationReducer([], { | ||
type: SET_LAST_LOCATION, | ||
payload: { lastLocation: '/users' } | ||
}) | ||
).toEqual({ lastLocation: '/users' }) | ||
}) | ||
}) |
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