2020-01-30 20:34:45 +01:00
|
|
|
import React from 'react'
|
|
|
|
import assert from 'assert'
|
|
|
|
import sinon from 'sinon'
|
|
|
|
import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
|
|
|
|
import { DEFAULT_ROUTE } from '../../../../helpers/constants/routes'
|
|
|
|
import EndOfFlowScreen from '../index'
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('End of Flow Screen', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
let wrapper
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
|
|
|
completeOnboarding: sinon.spy(),
|
|
|
|
}
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
wrapper = mountWithRouter(
|
|
|
|
<EndOfFlowScreen.WrappedComponent {...props} />
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('renders', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
assert.equal(wrapper.length, 1)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should navigate to the default route on click', function (done) {
|
2020-01-30 20:34:45 +01:00
|
|
|
const endOfFlowButton = wrapper.find('.btn-primary.first-time-flow__button')
|
|
|
|
endOfFlowButton.simulate('click')
|
|
|
|
|
|
|
|
setImmediate(() => {
|
|
|
|
assert(props.completeOnboarding.calledOnce)
|
2020-02-11 17:51:13 +01:00
|
|
|
assert(props.history.push.calledOnceWithExactly(DEFAULT_ROUTE))
|
2020-01-30 20:34:45 +01:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|