You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.3 KiB
129 lines
3.3 KiB
4 years ago
|
import React from 'react';
|
||
4 years ago
|
import { mountWithRouter } from '../../../../test/lib/render-helpers';
|
||
5 years ago
|
import {
|
||
|
DEFAULT_ROUTE,
|
||
4 years ago
|
LOCK_ROUTE,
|
||
5 years ago
|
INITIALIZE_WELCOME_ROUTE,
|
||
|
INITIALIZE_UNLOCK_ROUTE,
|
||
4 years ago
|
INITIALIZE_END_OF_FLOW_ROUTE,
|
||
4 years ago
|
} from '../../../helpers/constants/routes';
|
||
|
import FirstTimeFlowSwitch from './first-time-flow-switch.container';
|
||
5 years ago
|
|
||
4 years ago
|
describe('FirstTimeFlowSwitch', () => {
|
||
|
it('redirects to /welcome route with null props', () => {
|
||
4 years ago
|
const props = {
|
||
|
completedOnboarding: null,
|
||
|
isInitialized: null,
|
||
|
isUnlocked: null,
|
||
|
seedPhraseBackedUp: null,
|
||
4 years ago
|
};
|
||
4 years ago
|
const wrapper = mountWithRouter(
|
||
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
||
4 years ago
|
);
|
||
4 years ago
|
expect(
|
||
4 years ago
|
wrapper
|
||
|
.find('Lifecycle')
|
||
4 years ago
|
.find({ to: { pathname: INITIALIZE_WELCOME_ROUTE } }),
|
||
|
).toHaveLength(1);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('redirects to / route when completedOnboarding is true', () => {
|
||
5 years ago
|
const props = {
|
||
|
completedOnboarding: true,
|
||
4 years ago
|
};
|
||
5 years ago
|
const wrapper = mountWithRouter(
|
||
4 years ago
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
||
4 years ago
|
);
|
||
5 years ago
|
|
||
4 years ago
|
expect(
|
||
|
wrapper.find('Lifecycle').find({ to: { pathname: DEFAULT_ROUTE } }),
|
||
|
).toHaveLength(1);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('redirects to end of flow route when seedPhraseBackedUp is true', () => {
|
||
4 years ago
|
const props = {
|
||
|
completedOnboarding: false,
|
||
|
seedPhraseBackedUp: true,
|
||
4 years ago
|
};
|
||
4 years ago
|
const wrapper = mountWithRouter(
|
||
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
||
4 years ago
|
);
|
||
4 years ago
|
|
||
4 years ago
|
expect(
|
||
4 years ago
|
wrapper
|
||
|
.find('Lifecycle')
|
||
4 years ago
|
.find({ to: { pathname: INITIALIZE_END_OF_FLOW_ROUTE } }),
|
||
|
).toHaveLength(1);
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('redirects to end of flow route when seedPhraseBackedUp is false', () => {
|
||
4 years ago
|
const props = {
|
||
|
completedOnboarding: false,
|
||
|
seedPhraseBackedUp: false,
|
||
4 years ago
|
};
|
||
4 years ago
|
const wrapper = mountWithRouter(
|
||
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
||
4 years ago
|
);
|
||
4 years ago
|
|
||
4 years ago
|
expect(
|
||
4 years ago
|
wrapper
|
||
|
.find('Lifecycle')
|
||
4 years ago
|
.find({ to: { pathname: INITIALIZE_END_OF_FLOW_ROUTE } }),
|
||
|
).toHaveLength(1);
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('redirects to /lock route when isUnlocked is true', () => {
|
||
4 years ago
|
const props = {
|
||
|
completedOnboarding: false,
|
||
|
isUnlocked: true,
|
||
4 years ago
|
seedPhraseBackedUp: null,
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
|
const wrapper = mountWithRouter(
|
||
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
||
4 years ago
|
);
|
||
4 years ago
|
|
||
4 years ago
|
expect(
|
||
|
wrapper.find('Lifecycle').find({ to: { pathname: LOCK_ROUTE } }),
|
||
|
).toHaveLength(1);
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('redirects to /welcome route when isInitialized is false', () => {
|
||
5 years ago
|
const props = {
|
||
|
completedOnboarding: false,
|
||
|
isUnlocked: false,
|
||
|
isInitialized: false,
|
||
4 years ago
|
seedPhraseBackedUp: null,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
const wrapper = mountWithRouter(
|
||
4 years ago
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
||
4 years ago
|
);
|
||
5 years ago
|
|
||
4 years ago
|
expect(
|
||
4 years ago
|
wrapper
|
||
|
.find('Lifecycle')
|
||
4 years ago
|
.find({ to: { pathname: INITIALIZE_WELCOME_ROUTE } }),
|
||
|
).toHaveLength(1);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('redirects to /unlock route when isInitialized is true', () => {
|
||
5 years ago
|
const props = {
|
||
|
completedOnboarding: false,
|
||
|
isUnlocked: false,
|
||
|
isInitialized: true,
|
||
4 years ago
|
seedPhraseBackedUp: null,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
const wrapper = mountWithRouter(
|
||
4 years ago
|
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
|
||
4 years ago
|
);
|
||
5 years ago
|
|
||
4 years ago
|
expect(
|
||
4 years ago
|
wrapper
|
||
|
.find('Lifecycle')
|
||
4 years ago
|
.find({ to: { pathname: INITIALIZE_UNLOCK_ROUTE } }),
|
||
|
).toHaveLength(1);
|
||
4 years ago
|
});
|
||
|
});
|