diff --git a/src/components/Modal/Modal.test.tsx b/src/components/Modal/Modal.test.tsx
index af777d13b9..11cb35d9ec 100644
--- a/src/components/Modal/Modal.test.tsx
+++ b/src/components/Modal/Modal.test.tsx
@@ -2,18 +2,24 @@ import React from 'react'
import { render } from '@testing-library/react'
import { renderHook, act } from '@testing-library/react-hooks'
+jest.mock('../../deprecation')
+import { deprecationWarning } from '../../deprecation'
import { Modal, connectModal, useModal } from './Modal'
describe('Modal component', () => {
it('renders without errors', () => {
const { queryByTestId } = render(My Modal)
expect(queryByTestId('modal')).toBeInTheDocument()
+ expect(deprecationWarning).toHaveBeenCalledTimes(1)
})
})
const TestModal = (): React.ReactElement =>
My Modal
describe('connectModal', () => {
+ beforeEach(() => {
+ jest.clearAllMocks()
+ })
const mockClose = jest.fn()
describe('if isOpen is false', () => {
@@ -23,6 +29,7 @@ describe('connectModal', () => {
)
expect(queryByText('My Modal')).not.toBeInTheDocument()
+ expect(deprecationWarning).toHaveBeenCalledTimes(1)
})
})
@@ -33,13 +40,19 @@ describe('connectModal', () => {
)
expect(queryByText('My Modal')).toBeInTheDocument()
+ expect(deprecationWarning).toHaveBeenCalledTimes(2)
})
})
})
describe('useModal', () => {
+ beforeEach(() => {
+ jest.clearAllMocks()
+ })
+
it('provides state and functions for opening/closing a modal', () => {
const { result } = renderHook(() => useModal())
+ expect(deprecationWarning).toHaveBeenCalledTimes(1)
expect(result.current.isOpen).toEqual(false)
expect(typeof result.current.openModal).toBe('function')
expect(typeof result.current.closeModal).toBe('function')
@@ -49,11 +62,13 @@ describe('useModal', () => {
})
expect(result.current.isOpen).toEqual(true)
+ expect(deprecationWarning).toHaveBeenCalledTimes(2)
act(() => {
result.current.closeModal()
})
expect(result.current.isOpen).toEqual(false)
+ expect(deprecationWarning).toHaveBeenCalledTimes(3)
})
})