2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
2022-09-08 19:05:15 +02:00
|
|
|
import { fireEvent, screen } from '@testing-library/react';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
2021-03-16 22:00:08 +01:00
|
|
|
import Welcome from './welcome.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Welcome', () => {
|
|
|
|
afterAll(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
sinon.restore();
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-07-22 22:39:48 +02:00
|
|
|
it('routes to the metametrics screen when participateInMetaMetrics is not initialized', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-08 19:05:15 +02:00
|
|
|
renderWithProvider(<Welcome.WrappedComponent {...props} />);
|
|
|
|
|
|
|
|
const getStartedButton = screen.getByTestId('first-time-flow__button');
|
|
|
|
|
|
|
|
fireEvent.click(getStartedButton);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.history.push.getCall(0).args[0]).toStrictEqual(
|
2022-07-22 22:39:48 +02:00
|
|
|
'/initialize/metametrics-opt-in',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-07-22 22:39:48 +02:00
|
|
|
it('routes to select action when participateInMetaMetrics is initialized', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
welcomeScreenSeen: true,
|
|
|
|
participateInMetaMetrics: false,
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-08 19:05:15 +02:00
|
|
|
renderWithProvider(<Welcome.WrappedComponent {...props} />);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-08 19:05:15 +02:00
|
|
|
const getStartedButton = screen.getByTestId('first-time-flow__button');
|
|
|
|
|
|
|
|
fireEvent.click(getStartedButton);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.history.push.getCall(0).args[0]).toStrictEqual(
|
2022-07-22 22:39:48 +02:00
|
|
|
'/initialize/select-action',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|