mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
fix modal tests
This commit is contained in:
parent
5adba86e5e
commit
acb7ae4d35
@ -1,14 +1,17 @@
|
||||
import React from 'react'
|
||||
import { render } from '@testing-library/react'
|
||||
import Modal from './Modal'
|
||||
import ReactModal from 'react-modal'
|
||||
|
||||
describe('Modal', () => {
|
||||
it('renders without crashing', () => {
|
||||
const { container } = render(
|
||||
ReactModal.setAppElement(document.createElement('div'))
|
||||
|
||||
render(
|
||||
<Modal title="Hello" isOpen toggleModal={() => null}>
|
||||
Hello
|
||||
</Modal>
|
||||
)
|
||||
expect(container.firstChild).toBeInTheDocument()
|
||||
expect(document.querySelector('.ReactModalPortal')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
@ -2,7 +2,7 @@ import React from 'react'
|
||||
import ReactModal from 'react-modal'
|
||||
import styles from './Modal.module.scss'
|
||||
|
||||
ReactModal.setAppElement('#root')
|
||||
if (process.env.NODE_ENV !== 'test') ReactModal.setAppElement('#root')
|
||||
|
||||
const Modal = ({
|
||||
title,
|
||||
@ -11,7 +11,8 @@ const Modal = ({
|
||||
toggleModal,
|
||||
children,
|
||||
onAfterOpen,
|
||||
onRequestClose
|
||||
onRequestClose,
|
||||
...props
|
||||
}: {
|
||||
title: string
|
||||
description?: string
|
||||
@ -29,6 +30,7 @@ const Modal = ({
|
||||
contentLabel={title}
|
||||
className={styles.modal}
|
||||
overlayClassName={styles.modalOverlay}
|
||||
{...props}
|
||||
>
|
||||
<button className={styles.close} onClick={toggleModal}>
|
||||
×
|
||||
|
Loading…
Reference in New Issue
Block a user