2020-01-30 20:34:45 +01:00
|
|
|
import assert from 'assert'
|
2020-08-18 21:18:25 +02:00
|
|
|
import React from 'react'
|
2020-01-30 20:34:45 +01:00
|
|
|
import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
|
|
|
|
import {
|
|
|
|
DEFAULT_ROUTE,
|
|
|
|
LOCK_ROUTE,
|
|
|
|
INITIALIZE_WELCOME_ROUTE,
|
|
|
|
INITIALIZE_UNLOCK_ROUTE,
|
|
|
|
} from '../../../../helpers/constants/routes'
|
2020-08-19 18:27:05 +02:00
|
|
|
import FirstTimeFlowSwitch from '..'
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('FirstTimeFlowSwitch', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('redirects to /welcome route with no props', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent />,
|
2020-01-30 20:34:45 +01:00
|
|
|
)
|
|
|
|
assert.equal(wrapper.find('Lifecycle').find({ to: { pathname: INITIALIZE_WELCOME_ROUTE } }).length, 1)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('redirects to / route when completedOnboarding is true', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: true,
|
|
|
|
}
|
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2020-01-30 20:34:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert.equal(wrapper.find('Lifecycle').find({ to: { pathname: DEFAULT_ROUTE } }).length, 1)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('redirects to /lock route when isUnlocked is true ', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
isUnlocked: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2020-01-30 20:34:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert.equal(wrapper.find('Lifecycle').find({ to: { pathname: LOCK_ROUTE } }).length, 1)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('redirects to /welcome route when isInitialized is false', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
isUnlocked: false,
|
|
|
|
isInitialized: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2020-01-30 20:34:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert.equal(wrapper.find('Lifecycle').find({ to: { pathname: INITIALIZE_WELCOME_ROUTE } }).length, 1)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('redirects to /unlock route when isInitialized is true', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
isUnlocked: false,
|
|
|
|
isInitialized: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2020-01-30 20:34:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert.equal(wrapper.find('Lifecycle').find({ to: { pathname: INITIALIZE_UNLOCK_ROUTE } }).length, 1)
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|