2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { tick } from '../../../../test/lib/tick';
|
|
|
|
import { mountWithRouter } from '../../../../test/lib/render-helpers';
|
2021-03-16 22:00:08 +01:00
|
|
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
|
|
|
|
import EndOfFlowScreen from './end-of-flow.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('End of Flow Screen', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const props = {
|
|
|
|
history: {
|
2021-04-15 20:01:46 +02:00
|
|
|
push: sinon.stub(),
|
2020-01-30 20:34:45 +01:00
|
|
|
},
|
2021-04-15 20:01:46 +02:00
|
|
|
setCompletedOnboarding: sinon.stub().resolves(),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
wrapper = mountWithRouter(<EndOfFlowScreen.WrappedComponent {...props} />);
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('renders', () => {
|
|
|
|
expect(wrapper).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('should navigate to the default route on click', async () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const endOfFlowButton = wrapper.find(
|
|
|
|
'.btn-primary.first-time-flow__button',
|
|
|
|
);
|
|
|
|
endOfFlowButton.simulate('click');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
await tick();
|
|
|
|
|
|
|
|
expect(
|
|
|
|
props.history.push.calledOnceWithExactly(DEFAULT_ROUTE),
|
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|