focalboard/webapp/src/components/rootPortal.test.tsx

31 lines
922 B
TypeScript
Raw Normal View History

2020-10-20 21:50:53 +02:00
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
2020-10-20 21:52:56 +02:00
import React from 'react'
import {render} from '@testing-library/react'
import '@testing-library/jest-dom'
2020-10-20 21:52:56 +02:00
import RootPortal from './rootPortal'
describe('components/RootPortal', () => {
beforeEach(() => {
// Quick fix to disregard console error when unmounting a component
2020-10-20 21:50:53 +02:00
console.error = jest.fn()
2020-10-20 21:52:56 +02:00
})
test('should match snapshot', () => {
2020-10-20 21:50:53 +02:00
const rootPortalDiv = document.createElement('div')
2020-10-20 21:52:56 +02:00
rootPortalDiv.id = 'root-portal'
const {getByText, container} = render(
<RootPortal>
<div>{'Testing Portal'}</div>
</RootPortal>,
{container: document.body.appendChild(rootPortalDiv)},
2020-10-20 21:50:53 +02:00
)
2020-10-20 21:50:53 +02:00
expect(getByText('Testing Portal')).toBeVisible()
expect(container).toMatchSnapshot()
2020-10-20 21:52:56 +02:00
})
2020-10-20 21:50:53 +02:00
})