2020-01-30 20:34:45 +01:00
|
|
|
import assert from 'assert'
|
2020-08-18 21:18:25 +02:00
|
|
|
import React from 'react'
|
2020-01-30 20:34:45 +01:00
|
|
|
import sinon from 'sinon'
|
|
|
|
import configureMockStore from 'redux-mock-store'
|
|
|
|
import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
|
2020-08-19 18:27:05 +02:00
|
|
|
import Welcome from '..'
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Welcome', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const mockStore = {
|
|
|
|
metamask: {},
|
|
|
|
}
|
|
|
|
|
|
|
|
const store = configureMockStore()(mockStore)
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
after(function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
sinon.restore()
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('routes to select action when participateInMetaMetrics is not initialized', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-11-03 00:41:28 +01:00
|
|
|
<Welcome.WrappedComponent {...props} />,
|
|
|
|
store,
|
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',
|
|
|
|
)
|
2020-01-30 20:34:45 +01:00
|
|
|
getStartedButton.simulate('click')
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
props.history.push.getCall(0).args[0],
|
|
|
|
'/initialize/select-action',
|
|
|
|
)
|
2020-01-30 20:34:45 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('routes to correct password when participateInMetaMetrics is initialized', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
welcomeScreenSeen: true,
|
|
|
|
participateInMetaMetrics: false,
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const wrapper = mountWithRouter(
|
2020-11-03 00:41:28 +01:00
|
|
|
<Welcome.WrappedComponent {...props} />,
|
|
|
|
store,
|
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',
|
|
|
|
)
|
2020-01-30 20:34:45 +01:00
|
|
|
getStartedButton.simulate('click')
|
2020-11-03 00:41:28 +01:00
|
|
|
assert.equal(
|
|
|
|
props.history.push.getCall(0).args[0],
|
|
|
|
'/initialize/create-password',
|
|
|
|
)
|
2020-01-30 20:34:45 +01:00
|
|
|
})
|
|
|
|
})
|