2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { mountWithRouter } 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', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const mockStore = {
|
|
|
|
metamask: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const store = configureMockStore()(mockStore);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
afterAll(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
sinon.restore();
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('routes to select action 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
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-11-03 00:41:28 +01:00
|
|
|
<Welcome.WrappedComponent {...props} />,
|
|
|
|
store,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const getStartedButton = wrapper.find(
|
|
|
|
'.btn-primary.first-time-flow__button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
getStartedButton.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.history.push.getCall(0).args[0]).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
'/initialize/select-action',
|
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('routes to correct password 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
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-11-03 00:41:28 +01:00
|
|
|
<Welcome.WrappedComponent {...props} />,
|
|
|
|
store,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const getStartedButton = wrapper.find(
|
|
|
|
'.btn-primary.first-time-flow__button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
getStartedButton.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.history.push.getCall(0).args[0]).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
'/initialize/create-password',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|