2020-01-30 20:34:45 +01:00
|
|
|
import React from 'react'
|
|
|
|
import assert from 'assert'
|
|
|
|
import sinon from 'sinon'
|
|
|
|
import { mount } from 'enzyme'
|
|
|
|
import ConfirmResetAccount from '../index'
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Confirm Reset Account', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
let wrapper
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
hideModal: sinon.spy(),
|
|
|
|
resetAccount: sinon.stub().resolves(),
|
|
|
|
}
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
wrapper = mount(
|
|
|
|
<ConfirmResetAccount.WrappedComponent {...props} />, {
|
|
|
|
context: {
|
2020-02-15 21:34:12 +01:00
|
|
|
t: (str) => str,
|
2020-01-30 20:34:45 +01:00
|
|
|
},
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2020-01-30 20:34:45 +01:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
afterEach(function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
props.hideModal.resetHistory()
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('hides modal when nevermind button is clicked', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const nevermind = wrapper.find('.btn-default.modal-container__footer-button')
|
|
|
|
nevermind.simulate('click')
|
|
|
|
|
|
|
|
assert(props.hideModal.calledOnce)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('resets account and hidels modal when reset button is clicked', function (done) {
|
2020-01-30 20:34:45 +01:00
|
|
|
const reset = wrapper.find('.btn-danger.modal-container__footer-button')
|
|
|
|
reset.simulate('click')
|
|
|
|
|
|
|
|
setImmediate(() => {
|
|
|
|
assert(props.resetAccount.calledOnce)
|
|
|
|
assert(props.hideModal.calledOnce)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|