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 React from 'react'
|
||||||
import { render } from '@testing-library/react'
|
import { render } from '@testing-library/react'
|
||||||
import Modal from './Modal'
|
import Modal from './Modal'
|
||||||
|
import ReactModal from 'react-modal'
|
||||||
|
|
||||||
describe('Modal', () => {
|
describe('Modal', () => {
|
||||||
it('renders without crashing', () => {
|
it('renders without crashing', () => {
|
||||||
const { container } = render(
|
ReactModal.setAppElement(document.createElement('div'))
|
||||||
|
|
||||||
|
render(
|
||||||
<Modal title="Hello" isOpen toggleModal={() => null}>
|
<Modal title="Hello" isOpen toggleModal={() => null}>
|
||||||
Hello
|
Hello
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(document.querySelector('.ReactModalPortal')).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,7 @@ import React from 'react'
|
|||||||
import ReactModal from 'react-modal'
|
import ReactModal from 'react-modal'
|
||||||
import styles from './Modal.module.scss'
|
import styles from './Modal.module.scss'
|
||||||
|
|
||||||
ReactModal.setAppElement('#root')
|
if (process.env.NODE_ENV !== 'test') ReactModal.setAppElement('#root')
|
||||||
|
|
||||||
const Modal = ({
|
const Modal = ({
|
||||||
title,
|
title,
|
||||||
@ -11,7 +11,8 @@ const Modal = ({
|
|||||||
toggleModal,
|
toggleModal,
|
||||||
children,
|
children,
|
||||||
onAfterOpen,
|
onAfterOpen,
|
||||||
onRequestClose
|
onRequestClose,
|
||||||
|
...props
|
||||||
}: {
|
}: {
|
||||||
title: string
|
title: string
|
||||||
description?: string
|
description?: string
|
||||||
@ -29,6 +30,7 @@ const Modal = ({
|
|||||||
contentLabel={title}
|
contentLabel={title}
|
||||||
className={styles.modal}
|
className={styles.modal}
|
||||||
overlayClassName={styles.modalOverlay}
|
overlayClassName={styles.modalOverlay}
|
||||||
|
{...props}
|
||||||
>
|
>
|
||||||
<button className={styles.close} onClick={toggleModal}>
|
<button className={styles.close} onClick={toggleModal}>
|
||||||
×
|
×
|
||||||
|
Loading…
Reference in New Issue
Block a user