1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-03-20 20:45:00 +02:00

Add unit test for propertyMenu.tsx - basic setup

This commit is contained in:
Renjith 2021-03-19 07:41:11 -05:00
parent 19dab59551
commit 8b499f9035
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,3 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
module.exports = {};

View File

@ -32,6 +32,9 @@
"react-simplemde-editor": "^4.1.3"
},
"jest": {
"moduleNameMapper": {
"\\.(scss)$": "<rootDir>/__mocks__/styleMock.js"
},
"globals": {
"ts-jest": {
"tsConfig": "./src/tsconfig.json"

View File

@ -0,0 +1,39 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react'
import {render} from '@testing-library/react'
import '@testing-library/jest-dom'
import {IntlProvider} from 'react-intl'
import PropertyMenu from './propertyMenu'
describe('widgets/PropertyMenu', () => {
beforeEach(() => {
// Quick fix to disregard console error when unmounting a component
console.error = jest.fn()
document.execCommand = jest.fn()
})
test('should trigger callback when type change', () => {
const rootPortalDiv = document.createElement('div')
rootPortalDiv.id = 'root-portal'
const callback = jest.fn()
const {getByText} = render(
<IntlProvider locale='en'>
<PropertyMenu
propertyId={'id'}
propertyName={'email of a person'}
propertyType={'email'}
onTypeChanged={callback}
onNameChanged={callback}
onDelete={callback}
/>
</IntlProvider>,
{container: document.body.appendChild(rootPortalDiv)},
)
expect(getByText('Type: Email')).toBeVisible()
})
})