1
0
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:
Matthias Kretschmann 2019-07-05 13:54:39 +02:00
parent 5adba86e5e
commit acb7ae4d35
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 9 additions and 4 deletions

View File

@ -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()
})
})

View File

@ -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}>
&times;