-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philip Welber
committed
Jul 9, 2018
1 parent
12ee98b
commit d95f286
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
packages/blockchain-wallet-v4-frontend/src/data/modules/sfox/reducers.spec.js
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,65 @@ | ||
import { assoc } from 'ramda' | ||
import { Remote } from 'blockchain-wallet-v4/src' | ||
import reducer from './reducers' | ||
import * as actions from './actions' | ||
|
||
const INITIAL_STATE = { | ||
sfoxBusy: Remote.NotAsked, | ||
qaSellAddress: null, | ||
siftScienceEnabled: false | ||
} | ||
|
||
describe('sfox reducers', () => { | ||
it('should return the initial state', () => { | ||
expect(reducer(undefined, {})).toEqual(INITIAL_STATE) | ||
}) | ||
|
||
it('should handle NEXT_STEP', () => { | ||
const action = actions.nextStep('verify') | ||
const expectedState = assoc('signupStep', 'verify', INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
|
||
it('should handle SET_VERIFY_ERROR', () => { | ||
const error = 'Cannot verify' | ||
const action = actions.setVerifyError(error) | ||
const expectedState = assoc('verifyError', error, INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
|
||
it('should handle SFOX_NOT_ASKED', () => { | ||
const action = actions.sfoxNotAsked() | ||
const expectedState = assoc('sfoxBusy', Remote.NotAsked, INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
|
||
it('should handle SFOX_LOADING', () => { | ||
const action = actions.sfoxLoading() | ||
const expectedState = assoc('sfoxBusy', Remote.Loading, INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
|
||
it('should handle SFOX_SUCCESS', () => { | ||
const action = actions.sfoxSuccess() | ||
const expectedState = assoc('sfoxBusy', Remote.Success(action.payload), INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
|
||
it('should handle SFOX_FAILURE', () => { | ||
const action = actions.sfoxFailure() | ||
const expectedState = assoc('sfoxBusy', Remote.Failure(action.payload), INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
|
||
it('should handle ENABLE_SIFT_SCIENCE', () => { | ||
const action = actions.enableSiftScience() | ||
const expectedState = assoc('siftScienceEnabled', true, INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
|
||
it('should handle DISABLE_SIFT_SCIENCE', () => { | ||
const action = actions.disableSiftScience() | ||
const expectedState = assoc('siftScienceEnabled', false, INITIAL_STATE) | ||
expect(reducer(INITIAL_STATE, action)).toEqual(expectedState) | ||
}) | ||
}) |