diff --git a/webapp/__mocks__/styleMock.js b/webapp/__mocks__/styleMock.js new file mode 100644 index 00000000000..a8ab4d2522b --- /dev/null +++ b/webapp/__mocks__/styleMock.js @@ -0,0 +1,3 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. +module.exports = {}; diff --git a/webapp/package.json b/webapp/package.json index f7dc1e49924..0812e0114a2 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -32,6 +32,9 @@ "react-simplemde-editor": "^4.1.3" }, "jest": { + "moduleNameMapper": { + "\\.(scss)$": "/__mocks__/styleMock.js" + }, "globals": { "ts-jest": { "tsConfig": "./src/tsconfig.json" diff --git a/webapp/src/widgets/propertyMenu.test.tsx b/webapp/src/widgets/propertyMenu.test.tsx new file mode 100644 index 00000000000..b7936cfbfc8 --- /dev/null +++ b/webapp/src/widgets/propertyMenu.test.tsx @@ -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 display the type of property', () => { + const rootPortalDiv = document.createElement('div') + rootPortalDiv.id = 'root-portal' + const callback = jest.fn() + + const {getByText} = render( + + + , + {container: document.body.appendChild(rootPortalDiv)}, + ) + + expect(getByText('Type: Email')).toBeVisible() + }) +})