Skip to content

Commit

Permalink
test(SFOX): signup saga
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Welber committed Jun 26, 2018
1 parent ae1b5bc commit 427d3dc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import * as C from 'services/AlertService'
import { promptForSecondPassword } from 'services/SagaService'
import { path, prop } from 'ramda'

export default ({ coreSagas }) => {
const logLocation = 'modules/sfox/sagas'
export const logLocation = 'modules/sfox/sagas'

export default ({ coreSagas }) => {
const setBankManually = function * (action) {
try {
yield put(A.sfoxLoading())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import { put, select } from 'redux-saga/effects'

import { expectSaga, testSaga } from 'redux-saga-test-plan'
// import { dissocPath, curry } from 'ramda'
import * as matchers from 'redux-saga-test-plan/matchers'
import { throwError } from 'redux-saga-test-plan/providers'

import * as actions from '../../actions'
import * as sfoxActions from './actions.js'
import * as selectors from '../../selectors.js'

import sfoxSagas from './sagas'
import sfoxSagas, { logLocation } from './sagas'
// import * as C from 'services/AlertService'

describe('sfoxSagas', () => {
let api = { obtainSessionToken: () => { } }
let coreSagas = { wallet: { fetchWalletSaga: () => { } } }
let coreSagas = {
wallet: {
fetchWalletSaga: () => { }
},
data: {
sfox: {
signup: () => {}
}
}
}

describe('sfox signup', () => {
let { sfoxSignup } = sfoxSagas({
Expand All @@ -22,5 +34,47 @@ describe('sfoxSagas', () => {
it('should set loading', () => {
saga.next().put(sfoxActions.sfoxLoading())
})

it('should call signup', () => {
saga.next().call(coreSagas.data.sfox.signup)
})

it('should select the profile', () => {
saga.next().select(selectors.core.data.sfox.getProfile)
})

describe('successful signup', () => {
it('should be success', () => {
const fakeUser = { name: 'Shmee', id: 10 }
return expectSaga(sfoxSignup)
.put({ type: '@COMPONENT.SFOX_LOADING' })
.provide([
[matchers.call.fn(coreSagas.data.sfox.signup)]
])
.provide([
[select(selectors.core.data.sfox.getProfile), fakeUser]
])
.put({ type: '@COMPONENT.SFOX_SUCCESS' })
.put({ type: '@COMPONENT.ENABLE_SIFT_SCIENCE' })
.put({ type: '@COMPONENT.NEXT_STEP', payload: 'verify' })
.run()
})
})

describe('signup error', () => {
it('should throw', () => {
const profileError = {error: 'signup_error'}
return expectSaga(sfoxSignup)
.put({ type: '@COMPONENT.SFOX_LOADING' })
.provide([
[matchers.call.fn(coreSagas.data.sfox.signup)]
])
.provide([
[select(selectors.core.data.sfox.getProfile), profileError]
])
.put({ type: '@COMPONENT.SFOX_NOT_ASKED' })
.run()
})
})
})
})

0 comments on commit 427d3dc

Please sign in to comment.