Skip to content

Commit

Permalink
refactor(Jumio): getOrFail if jumio completes without token
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jul 23, 2018
1 parent 5733dce commit 5845ed8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Remote } from 'blockchain-wallet-v4/src'

export const sellDescription = `Exchange Trade SFX-`
export const logLocation = 'modules/sfox/sagas'
export const missingJumioToken = 'missing_jumio_token'

export default ({ coreSagas }) => {
const setBankManually = function*(action) {
Expand Down Expand Up @@ -267,7 +268,7 @@ export default ({ coreSagas }) => {
const accountsR = yield select(selectors.core.data.sfox.getAccounts)
const accounts = accountsR.getOrElse([])
// If user has not set up jumio and they have bank accounts
if (status === 'missing_token' && accounts.length) {
if (status === missingJumioToken && accounts.length) {
const confirmed = yield call(confirm, {
title: CC.VERIFY_IDENTITY_TITLE,
image: 'identity-verification',
Expand Down Expand Up @@ -296,7 +297,7 @@ export default ({ coreSagas }) => {
const tokenR = yield select(selectors.core.kvStore.buySell.getSfoxJumio)
const accountsR = yield select(selectors.core.data.sfox.getAccounts)
const accounts = accountsR.getOrElse([])
let token = tokenR.getOrElse({})
let token = tokenR.getOrFail(missingJumioToken)
token.completed = true
accounts.length
? yield put(modalActions.closeAllModals())
Expand All @@ -315,7 +316,7 @@ export default ({ coreSagas }) => {
const tokenR = yield select(selectors.core.kvStore.buySell.getSfoxJumio)
const token = tokenR.getOrFail()
const profile = profileR.getOrElse({})
if (!token) return 'missing_token'
if (!token) return missingJumioToken
const status = yield apply(profile, profile.fetchJumioStatus, [token.id])
yield put(A.fetchJumioStatusSuccess(status))
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { coreSagasFactory, Remote } from 'blockchain-wallet-v4/src'
import * as actions from '../../actions'
import * as sfoxActions from './actions.js'
import * as selectors from '../../selectors.js'
import sfoxSagas, { logLocation } from './sagas'
import sfoxSagas, { logLocation, missingJumioToken } from './sagas'
import * as C from 'services/AlertService'
import { promptForSecondPassword, confirm } from 'services/SagaService'
import settings from 'config'
Expand Down Expand Up @@ -584,7 +584,7 @@ describe('sfoxSagas', () => {
})

it('should select bank accounts', () => {
saga.next('missing_token').select(selectors.core.data.sfox.getAccounts)
saga.next(missingJumioToken).select(selectors.core.data.sfox.getAccounts)
})

it('should prompt the user to confirm their id verification if missing_token and accounts', () => {
Expand Down

0 comments on commit 5845ed8

Please sign in to comment.