2022-04-08 07:00:31 -04:00
|
|
|
import { expect } from 'chai'
|
|
|
|
import { screen, render } from '@testing-library/react'
|
|
|
|
import fetchMock from 'fetch-mock'
|
|
|
|
|
|
|
|
import LeaveModalContent from '../../../../../../frontend/js/features/settings/components/leave/modal-content'
|
|
|
|
|
|
|
|
describe('<LeaveModalContent />', function () {
|
2022-04-08 07:01:21 -04:00
|
|
|
beforeEach(function () {
|
|
|
|
window.metaAttributesCache = new Map()
|
2022-04-22 09:49:26 -04:00
|
|
|
window.metaAttributesCache.set('ol-ExposedSettings', { isOverleaf: true })
|
2022-04-08 07:01:21 -04:00
|
|
|
window.metaAttributesCache.set('ol-hasPassword', true)
|
|
|
|
})
|
|
|
|
|
2022-04-08 07:00:31 -04:00
|
|
|
afterEach(function () {
|
2022-04-08 07:01:21 -04:00
|
|
|
window.metaAttributesCache = new Map()
|
2022-04-08 07:00:31 -04:00
|
|
|
fetchMock.reset()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('disable delete button if form is not valid', function () {
|
|
|
|
render(
|
|
|
|
<LeaveModalContent
|
|
|
|
handleHide={() => {}}
|
|
|
|
inFlight={false}
|
|
|
|
setInFlight={() => {}}
|
|
|
|
/>
|
|
|
|
)
|
2022-04-08 07:01:21 -04:00
|
|
|
screen.getByLabelText('Email')
|
2022-04-08 07:00:31 -04:00
|
|
|
|
|
|
|
const deleteButton = screen.getByRole('button', {
|
|
|
|
name: 'Delete',
|
|
|
|
})
|
|
|
|
expect(deleteButton.hasAttribute('disabled')).to.be.true
|
|
|
|
})
|
2022-04-08 07:01:21 -04:00
|
|
|
|
|
|
|
it('shows no password message', function () {
|
|
|
|
window.metaAttributesCache.set('ol-isSaas', true)
|
|
|
|
window.metaAttributesCache.set('ol-hasPassword', false)
|
|
|
|
render(
|
|
|
|
<LeaveModalContent
|
|
|
|
handleHide={() => {}}
|
|
|
|
inFlight={false}
|
|
|
|
setInFlight={() => {}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
|
|
|
|
const link = screen.getByRole('link', {
|
|
|
|
name: 'Please use the password reset form to set a password before deleting your account',
|
|
|
|
})
|
|
|
|
expect(link.getAttribute('href')).to.equal('/user/password/reset')
|
|
|
|
})
|
2022-04-08 07:00:31 -04:00
|
|
|
})
|