overleaf/services/web/test/frontend/components/shared/accessible-modal.spec.tsx
Alf Eaton e95ad3e71b Tidy up shared React components (#9509)
GitOrigin-RevId: b8029b65c95ccdac89587d484e2599e25fe44302
2023-01-06 09:03:47 +00:00

36 lines
958 B
TypeScript

import { Modal } from 'react-bootstrap'
import AccessibleModal from '../../../../frontend/js/shared/components/accessible-modal'
describe('AccessibleModal', function () {
it('renders a visible modal', function () {
const handleHide = cy.stub()
cy.mount(
<AccessibleModal onHide={handleHide} show>
<Modal.Header closeButton>
<Modal.Title>Test</Modal.Title>
</Modal.Header>
<Modal.Body>Some content</Modal.Body>
</AccessibleModal>
)
cy.findByRole('dialog').should('have.length', 1)
})
it('does not render a hidden modal', function () {
const handleHide = cy.stub()
cy.mount(
<AccessibleModal onHide={handleHide}>
<Modal.Header closeButton>
<Modal.Title>Test</Modal.Title>
</Modal.Header>
<Modal.Body>Some content</Modal.Body>
</AccessibleModal>
)
cy.findByRole('dialog', { hidden: true }).should('have.length', 0)
})
})