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:
parent
19dab59551
commit
8b499f9035
3
webapp/__mocks__/styleMock.js
Normal file
3
webapp/__mocks__/styleMock.js
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
module.exports = {};
|
@ -32,6 +32,9 @@
|
||||
"react-simplemde-editor": "^4.1.3"
|
||||
},
|
||||
"jest": {
|
||||
"moduleNameMapper": {
|
||||
"\\.(scss)$": "<rootDir>/__mocks__/styleMock.js"
|
||||
},
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"tsConfig": "./src/tsconfig.json"
|
||||
|
39
webapp/src/widgets/propertyMenu.test.tsx
Normal file
39
webapp/src/widgets/propertyMenu.test.tsx
Normal 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()
|
||||
})
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user