overleaf/services/web/test/frontend/features/settings/components/leave-section.test.tsx
Timothée Alby cf2dfc6bf1 Merge pull request #7593 from overleaf/ta-settings-migration
[SettingsPage] Integration Branch

GitOrigin-RevId: 5a3c26b2a02d716c4ae3981e3f08b811ae307725
2022-04-25 08:05:12 +00:00

49 lines
1.2 KiB
TypeScript

import {
fireEvent,
screen,
waitForElementToBeRemoved,
render,
} from '@testing-library/react'
import LeaveSection from '../../../../../frontend/js/features/settings/components/leave-section'
describe('<LeaveSection />', function () {
beforeEach(function () {
window.metaAttributesCache = new Map()
window.metaAttributesCache.set('ol-usersEmail', 'foo@bar.com')
window.metaAttributesCache.set('ol-ExposedSettings', { isOverleaf: true })
window.metaAttributesCache.set('ol-hasPassword', true)
})
afterEach(function () {
window.metaAttributesCache = new Map()
})
it('opens modal', async function () {
render(<LeaveSection />)
const button = screen.getByRole('button', {
name: 'Delete your account',
})
fireEvent.click(button)
await screen.findByText('Delete Account')
})
it('closes modal', async function () {
render(<LeaveSection />)
fireEvent.click(
screen.getByRole('button', {
name: 'Delete your account',
})
)
const cancelButton = screen.getByRole('button', {
name: 'Close',
})
fireEvent.click(cancelButton)
await waitForElementToBeRemoved(() => screen.getByText('Delete Account'))
})
})