2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { mountWithRouter } from '../../../../test/lib/render-helpers';
|
2020-01-30 20:34:45 +01:00
|
|
|
import {
|
|
|
|
DEFAULT_ROUTE,
|
2020-11-09 14:50:24 +01:00
|
|
|
LOCK_ROUTE,
|
2020-01-30 20:34:45 +01:00
|
|
|
INITIALIZE_WELCOME_ROUTE,
|
|
|
|
INITIALIZE_UNLOCK_ROUTE,
|
2020-11-10 22:27:08 +01:00
|
|
|
INITIALIZE_END_OF_FLOW_ROUTE,
|
2021-03-16 22:00:08 +01:00
|
|
|
} from '../../../helpers/constants/routes';
|
|
|
|
import FirstTimeFlowSwitch from './first-time-flow-switch.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('FirstTimeFlowSwitch', () => {
|
|
|
|
it('redirects to /welcome route with null props', () => {
|
2020-11-10 22:27:08 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: null,
|
|
|
|
isInitialized: null,
|
|
|
|
isUnlocked: null,
|
|
|
|
seedPhraseBackedUp: null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-11-10 22:27:08 +01:00
|
|
|
const wrapper = mountWithRouter(
|
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper
|
|
|
|
.find('Lifecycle')
|
2021-04-15 20:01:46 +02:00
|
|
|
.find({ to: { pathname: INITIALIZE_WELCOME_ROUTE } }),
|
|
|
|
).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('redirects to / route when completedOnboarding is true', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
|
|
|
wrapper.find('Lifecycle').find({ to: { pathname: DEFAULT_ROUTE } }),
|
|
|
|
).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('redirects to end of flow route when seedPhraseBackedUp is true', () => {
|
2020-11-10 22:27:08 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
seedPhraseBackedUp: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-11-10 22:27:08 +01:00
|
|
|
const wrapper = mountWithRouter(
|
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-10 22:27:08 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-10 22:27:08 +01:00
|
|
|
wrapper
|
|
|
|
.find('Lifecycle')
|
2021-04-15 20:01:46 +02:00
|
|
|
.find({ to: { pathname: INITIALIZE_END_OF_FLOW_ROUTE } }),
|
|
|
|
).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-10 22:27:08 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('redirects to end of flow route when seedPhraseBackedUp is false', () => {
|
2020-11-10 22:27:08 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
seedPhraseBackedUp: false,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-11-10 22:27:08 +01:00
|
|
|
const wrapper = mountWithRouter(
|
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-10 22:27:08 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-10 22:27:08 +01:00
|
|
|
wrapper
|
|
|
|
.find('Lifecycle')
|
2021-04-15 20:01:46 +02:00
|
|
|
.find({ to: { pathname: INITIALIZE_END_OF_FLOW_ROUTE } }),
|
|
|
|
).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-10 22:27:08 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('redirects to /lock route when isUnlocked is true', () => {
|
2020-11-09 14:50:24 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
isUnlocked: true,
|
2020-11-10 22:27:08 +01:00
|
|
|
seedPhraseBackedUp: null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-11-09 14:50:24 +01:00
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
|
|
|
wrapper.find('Lifecycle').find({ to: { pathname: LOCK_ROUTE } }),
|
|
|
|
).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('redirects to /welcome route when isInitialized is false', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
isUnlocked: false,
|
|
|
|
isInitialized: false,
|
2020-11-10 22:27:08 +01:00
|
|
|
seedPhraseBackedUp: null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper
|
|
|
|
.find('Lifecycle')
|
2021-04-15 20:01:46 +02:00
|
|
|
.find({ to: { pathname: INITIALIZE_WELCOME_ROUTE } }),
|
|
|
|
).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('redirects to /unlock route when isInitialized is true', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
completedOnboarding: false,
|
|
|
|
isUnlocked: false,
|
|
|
|
isInitialized: true,
|
2020-11-10 22:27:08 +01:00
|
|
|
seedPhraseBackedUp: null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-07-14 17:20:41 +02:00
|
|
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper
|
|
|
|
.find('Lifecycle')
|
2021-04-15 20:01:46 +02:00
|
|
|
.find({ to: { pathname: INITIALIZE_UNLOCK_ROUTE } }),
|
|
|
|
).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|