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

View File

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