2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
2022-08-09 17:37:29 +02:00
|
|
|
import { fireEvent, screen } from '@testing-library/react';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { tick } from '../../../../test/lib/tick';
|
2022-08-09 17:37:29 +02:00
|
|
|
import { renderWithProvider } 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', () => {
|
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(),
|
2022-10-04 17:52:42 +02:00
|
|
|
setOnBoardedInThisUISession: sinon.stub(),
|
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(() => {
|
2022-08-09 17:37:29 +02:00
|
|
|
renderWithProvider(<EndOfFlowScreen.WrappedComponent {...props} />);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-08-09 17:37:29 +02:00
|
|
|
it('should render', () => {
|
|
|
|
const endOfFlow = screen.queryByTestId('end-of-flow');
|
|
|
|
expect(endOfFlow).toBeInTheDocument();
|
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 () => {
|
2022-08-09 17:37:29 +02:00
|
|
|
const endOfFlowButton = screen.getByTestId('EOF-complete-button');
|
|
|
|
fireEvent.click(endOfFlowButton);
|
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
|
|
|
});
|
|
|
|
});
|