diff --git a/webapp/src/components/addContentMenuItem.test.tsx b/webapp/src/components/addContentMenuItem.test.tsx index 61fbe5a81..c13b09358 100644 --- a/webapp/src/components/addContentMenuItem.test.tsx +++ b/webapp/src/components/addContentMenuItem.test.tsx @@ -1,11 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {ReactElement} from 'react' +import React from 'react' import {render, screen, waitFor} from '@testing-library/react' import '@testing-library/jest-dom' -import {IntlProvider} from 'react-intl' import {mocked} from 'ts-jest/utils' @@ -15,6 +14,8 @@ import mutator from '../mutator' import {TestBlockFactory} from '../test/testBlockFactory' +import {wrapIntl} from '../testUtils' + import AddContentMenuItem from './addContentMenuItem' import './content/textElement' @@ -22,9 +23,6 @@ import './content/imageElement' import './content/dividerElement' import './content/checkboxElement' -const wrapIntl = (children: ReactElement) => ( - {children} -) const board = TestBlockFactory.createBoard() const card = TestBlockFactory.createCard(board) diff --git a/webapp/src/components/blockIconSelector.test.tsx b/webapp/src/components/blockIconSelector.test.tsx index 2585a03d2..9a2eb9b26 100644 --- a/webapp/src/components/blockIconSelector.test.tsx +++ b/webapp/src/components/blockIconSelector.test.tsx @@ -1,23 +1,23 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {ReactElement} from 'react' +import React from 'react' import {fireEvent, render, screen} from '@testing-library/react' import userEvent from '@testing-library/user-event' import '@testing-library/jest-dom' -import {IntlProvider} from 'react-intl' import {mocked} from 'ts-jest/utils' import mutator from '../mutator' +import {wrapIntl} from '../testUtils' + import {TestBlockFactory} from '../test/testBlockFactory' import BlockIconSelector from './blockIconSelector' -const wrapIntl = (children: ReactElement) => {children} const board = TestBlockFactory.createBoard() const icon = '👍' diff --git a/webapp/src/components/cardDetail/cardDetailContents.test.tsx b/webapp/src/components/cardDetail/cardDetailContents.test.tsx index cb361d433..6883009ee 100644 --- a/webapp/src/components/cardDetail/cardDetailContents.test.tsx +++ b/webapp/src/components/cardDetail/cardDetailContents.test.tsx @@ -4,26 +4,14 @@ import React from 'react' import {fireEvent, render} from '@testing-library/react' -import {IntlProvider} from 'react-intl' import {act} from 'react-dom/test-utils' -import {DndProvider} from 'react-dnd' -import {HTML5Backend} from 'react-dnd-html5-backend' - import {TestBlockFactory} from '../../test/testBlockFactory' -import {mockDOM} from '../../testUtils' +import {mockDOM, wrapDNDIntl} from '../../testUtils' import CardDetailContents from './cardDetailContents' -const wrapProviders = (children: any) => { - return ( - - {children} - - ) -} - global.fetch = jest.fn() beforeAll(() => { @@ -60,7 +48,7 @@ describe('components/cardDetail/cardDetailContents', () => { const card = TestBlockFactory.createCard(board) test('should match snapshot', async () => { - const component = wrapProviders(( + const component = wrapDNDIntl(( { test('should match snapshot with contents array', async () => { const contents = [TestBlockFactory.createDivider(card)] - const component = wrapProviders(( + const component = wrapDNDIntl(( { }) test('should match snapshot after onBlur triggers', async () => { - const component = wrapProviders(( + const component = wrapDNDIntl(( { test('should match snapshot with contents array that has array inside it', async () => { const contents = [TestBlockFactory.createDivider(card), [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)]] - const component = wrapProviders(( + const component = wrapDNDIntl(( { test('should match snapshot after drag and drop event', async () => { const contents = [TestBlockFactory.createDivider(card), [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)]] card.fields.contentOrder = contents.map((content) => (Array.isArray(content) ? content.map((c) => c.id) : (content as any).id)) - const component = wrapProviders(( + const component = wrapDNDIntl(( { test('should match snapshot after drag and drop event 2', async () => { const contents = [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)] card.fields.contentOrder = contents.map((content) => (Array.isArray(content) ? content.map((c) => c.id) : (content as any).id)) - const component = wrapProviders(( + const component = wrapDNDIntl(( { test('should match snapshot after drag and drop event 3', async () => { const contents = [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)] card.fields.contentOrder = contents.map((content) => (Array.isArray(content) ? content.map((c) => c.id) : (content as any).id)) - const component = wrapProviders(( + const component = wrapDNDIntl(( { FetchMock.fn.mockReset() }) -const wrapIntl = (children: any) => {children} - describe('components/cardDetail/CardDetailProperties', () => { const board = TestBlockFactory.createBoard() board.fields.cardProperties = [ diff --git a/webapp/src/components/content/checkboxElement.test.tsx b/webapp/src/components/content/checkboxElement.test.tsx index d6b912ecf..5bcbe1581 100644 --- a/webapp/src/components/content/checkboxElement.test.tsx +++ b/webapp/src/components/content/checkboxElement.test.tsx @@ -4,7 +4,8 @@ import React from 'react' import {fireEvent, render} from '@testing-library/react' import '@testing-library/jest-dom' -import {IntlProvider} from 'react-intl' + +import {wrapIntl} from '../../testUtils' import {ContentBlock} from '../../blocks/contentBlock' @@ -12,8 +13,6 @@ import CheckboxElement from './checkboxElement' const fetchMock = require('fetch-mock-jest') -const wrapIntl = (children: any) => {children} - describe('components/content/CheckboxElement', () => { const defaultBlock: ContentBlock = { id: 'test-id', diff --git a/webapp/src/components/globalHeader/globalHeader.test.tsx b/webapp/src/components/globalHeader/globalHeader.test.tsx index cb157f939..6f1ce9fed 100644 --- a/webapp/src/components/globalHeader/globalHeader.test.tsx +++ b/webapp/src/components/globalHeader/globalHeader.test.tsx @@ -6,13 +6,11 @@ import {Provider as ReduxProvider} from 'react-redux' import {render} from '@testing-library/react' -import {IntlProvider} from 'react-intl' - import configureStore from 'redux-mock-store' -import GlobalHeader from './globalHeader' +import {wrapIntl} from '../../testUtils' -const wrapIntl = (children: any) => {children} +import GlobalHeader from './globalHeader' describe('components/sidebar/GlobalHeader', () => { const mockStore = configureStore([]) diff --git a/webapp/src/components/globalHeader/globalHeaderSettingsMenu.test.tsx b/webapp/src/components/globalHeader/globalHeaderSettingsMenu.test.tsx index c27cf1bf9..83e2afbff 100644 --- a/webapp/src/components/globalHeader/globalHeaderSettingsMenu.test.tsx +++ b/webapp/src/components/globalHeader/globalHeaderSettingsMenu.test.tsx @@ -6,14 +6,12 @@ import {Provider as ReduxProvider} from 'react-redux' import {render} from '@testing-library/react' -import {IntlProvider} from 'react-intl' - import userEvent from '@testing-library/user-event' import configureStore from 'redux-mock-store' -import GlobalHeaderSettingsMenu from './globalHeaderSettingsMenu' +import {wrapIntl} from '../../testUtils' -const wrapIntl = (children: any) => {children} +import GlobalHeaderSettingsMenu from './globalHeaderSettingsMenu' describe('components/sidebar/GlobalHeaderSettingsMenu', () => { const mockStore = configureStore([]) diff --git a/webapp/src/components/properties/dateRange/dateRange.test.tsx b/webapp/src/components/properties/dateRange/dateRange.test.tsx index 87986518b..ae4336c48 100644 --- a/webapp/src/components/properties/dateRange/dateRange.test.tsx +++ b/webapp/src/components/properties/dateRange/dateRange.test.tsx @@ -4,13 +4,13 @@ import React from 'react' import {render} from '@testing-library/react' import userEvent from '@testing-library/user-event' - -import '@testing-library/jest-dom' import {IntlProvider} from 'react-intl' -import DateRange from '../dateRange/dateRange' +import '@testing-library/jest-dom' -const wrapIntl = (children: any) => {children} +import {wrapIntl} from '../../../testUtils' + +import DateRange from '../dateRange/dateRange' // create Dates for specific days for this year. const June15 = new Date(Date.UTC(new Date().getFullYear(), 5, 15, 12)) diff --git a/webapp/src/components/properties/lastModifiedAt/lastModifiedAt.test.tsx b/webapp/src/components/properties/lastModifiedAt/lastModifiedAt.test.tsx index c16e6bd74..3e6c5ef53 100644 --- a/webapp/src/components/properties/lastModifiedAt/lastModifiedAt.test.tsx +++ b/webapp/src/components/properties/lastModifiedAt/lastModifiedAt.test.tsx @@ -3,15 +3,14 @@ import React from 'react' import {render} from '@testing-library/react' -import {IntlProvider} from 'react-intl' + +import {wrapIntl} from '../../../testUtils' import {createCard} from '../../../blocks/card' import {createCommentBlock} from '../../../blocks/commentBlock' import LastModifiedAt from './lastModifiedAt' -const wrapIntl = (children: any) => {children} - describe('componnets/properties/lastModifiedAt', () => { test('should match snapshot', () => { const card = createCard() diff --git a/webapp/src/components/properties/user/user.test.tsx b/webapp/src/components/properties/user/user.test.tsx index 679f2f0bb..896a2562d 100644 --- a/webapp/src/components/properties/user/user.test.tsx +++ b/webapp/src/components/properties/user/user.test.tsx @@ -3,17 +3,18 @@ import React from 'react' import {Provider as ReduxProvider} from 'react-redux' -import {IntlProvider} from 'react-intl' + import {render, waitFor} from '@testing-library/react' + import configureStore from 'redux-mock-store' import {act} from 'react-dom/test-utils' import userEvent from '@testing-library/user-event' -import UserProperty from './user' +import {wrapIntl} from '../../../testUtils' -const wrapIntl = (children: any) => {children} +import UserProperty from './user' describe('components/properties/user', () => { const mockStore = configureStore([]) diff --git a/webapp/src/components/propertyValueElement.test.tsx b/webapp/src/components/propertyValueElement.test.tsx index 0e71e69e4..d9c5f78a6 100644 --- a/webapp/src/components/propertyValueElement.test.tsx +++ b/webapp/src/components/propertyValueElement.test.tsx @@ -4,11 +4,10 @@ import React from 'react' import {render} from '@testing-library/react' import '@testing-library/jest-dom' -import {IntlProvider} from 'react-intl' + +import {wrapDNDIntl} from '../testUtils' import 'isomorphic-fetch' -import {DndProvider} from 'react-dnd' -import {HTML5Backend} from 'react-dnd-html5-backend' import {IPropertyTemplate, IPropertyOption} from '../blocks/board' @@ -16,14 +15,6 @@ import {TestBlockFactory} from '../test/testBlockFactory' import PropertyValueElement from './propertyValueElement' -const wrapProviders = (children: any) => { - return ( - - {children} - - ) -} - describe('components/propertyValueElement', () => { const board = TestBlockFactory.createBoard() const card = TestBlockFactory.createCard(board) @@ -31,7 +22,7 @@ describe('components/propertyValueElement', () => { test('should match snapshot, select', async () => { const propertyTemplate = board.fields.cardProperties.find((p) => p.id === 'property1') - const component = wrapProviders( + const component = wrapDNDIntl( { test('should match snapshot, select, read-only', async () => { const propertyTemplate = board.fields.cardProperties.find((p) => p.id === 'property1') - const component = wrapProviders( + const component = wrapDNDIntl( { options, } card.fields.properties.multiSelect = ['ms1', 'ms2'] - const component = wrapProviders( + const component = wrapDNDIntl( { } card.fields.properties.property_url = ['http://localhost'] - const component = wrapProviders( + const component = wrapDNDIntl( { } card.fields.properties.property_url = ['http://localhost'] - const component = wrapProviders( + const component = wrapDNDIntl( { } card.fields.properties.person = ['value1', 'value2'] - const component = wrapProviders( + const component = wrapDNDIntl( { } card.fields.properties.date = ['invalid date'] - const component = wrapProviders( + const component = wrapDNDIntl( { - return ( - {children} - ) -} - beforeAll(() => { mockMatchMedia({matches: true}) }) @@ -67,7 +58,7 @@ describe('components/sidebarSidebar', () => { const history = createMemoryHistory() - const component = wrapProviders( + const component = wrapIntl( @@ -105,7 +96,7 @@ describe('components/sidebarSidebar', () => { const history = createMemoryHistory() - const component = wrapProviders( + const component = wrapIntl( diff --git a/webapp/src/components/sidebar/sidebarSettingsMenu.test.tsx b/webapp/src/components/sidebar/sidebarSettingsMenu.test.tsx index e27236f07..ecd9ab4eb 100644 --- a/webapp/src/components/sidebar/sidebarSettingsMenu.test.tsx +++ b/webapp/src/components/sidebar/sidebarSettingsMenu.test.tsx @@ -6,17 +6,15 @@ import {Provider as ReduxProvider} from 'react-redux' import {render} from '@testing-library/react' -import {IntlProvider} from 'react-intl' - import userEvent from '@testing-library/user-event' import configureStore from 'redux-mock-store' +import {wrapIntl} from '../../testUtils' + import {defaultThemeName} from '../../theme' import SidebarSettingsMenu from './sidebarSettingsMenu' -const wrapIntl = (children: any) => {children} - describe('components/sidebar/SidebarSettingsMenu', () => { const mockStore = configureStore([]) let store = mockStore({}) diff --git a/webapp/src/components/table/calculation/calculationRow.test.tsx b/webapp/src/components/table/calculation/calculationRow.test.tsx index 0ec5f5cd6..d8624a60d 100644 --- a/webapp/src/components/table/calculation/calculationRow.test.tsx +++ b/webapp/src/components/table/calculation/calculationRow.test.tsx @@ -1,9 +1,5 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. - -import {DndProvider} from 'react-dnd' -import {HTML5Backend} from 'react-dnd-html5-backend' -import {IntlProvider} from 'react-intl' import React from 'react' import {render} from '@testing-library/react' @@ -12,6 +8,7 @@ import '@testing-library/jest-dom' import {TestBlockFactory} from '../../../test/testBlockFactory' import {FetchMock} from '../../../test/fetchMock' import 'isomorphic-fetch' +import {wrapDNDIntl} from '../../../testUtils' import CalculationRow from './calculationRow' @@ -21,14 +18,6 @@ beforeEach(() => { FetchMock.fn.mockReset() }) -const wrapProviders = (children: any) => { - return ( - - {children} - - ) -} - describe('components/table/calculation/CalculationRow', () => { const board = TestBlockFactory.createBoard() board.fields.cardProperties.push({ @@ -66,7 +55,7 @@ describe('components/table/calculation/CalculationRow', () => { test('should render three calculation elements', async () => { FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify([board, view, card]))) - const component = wrapProviders( + const component = wrapDNDIntl( { property_4: 'countUniqueValue', } - const component = wrapProviders( + const component = wrapDNDIntl( { FetchMock.fn.mockReset() }) -const wrapProviders = (children: any) => { - return ( - - {children} - - ) -} - describe('components/table/Table', () => { const board = TestBlockFactory.createBoard() const view = TestBlockFactory.createBoardView(board) @@ -80,7 +70,7 @@ describe('components/table/Table', () => { const mockStore = configureStore([]) const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( { const mockStore = configureStore([]) const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl(
{ const mockStore = configureStore([]) const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl(
{ }, }) - const component = wrapProviders( + const component = wrapDNDIntl(
{ }, }) - const component = wrapProviders( + const component = wrapDNDIntl(
{ }, }) - const component = wrapProviders( + const component = wrapDNDIntl(
{ }, }) - const component = wrapProviders( + const component = wrapDNDIntl(
{ - return ( - - {children} - - ) -} - const board = TestBlockFactory.createBoard() const view = TestBlockFactory.createBoardView(board) @@ -52,7 +42,7 @@ const boardTreeGroup = { } test('should match snapshot, no groups', async () => { - const component = wrapProviders( + const component = wrapDNDIntl( { }) test('should match snapshot with Group', async () => { - const component = wrapProviders( + const component = wrapDNDIntl( { }) test('should match snapshot on read only', async () => { - const component = wrapProviders( + const component = wrapDNDIntl( { const collapsedOptionsView = TestBlockFactory.createBoardView(board) collapsedOptionsView.fields.collapsedOptionIds = [boardTreeGroup.option.id] - const component = wrapProviders( + const component = wrapDNDIntl( { test('should match snapshot, add new', async () => { const addNew = jest.fn() - const component = wrapProviders( + const component = wrapDNDIntl( { }) test('should match snapshot, edit title', async () => { - const component = wrapProviders( + const component = wrapDNDIntl( { - return ( - - {children} - - ) -} - describe('components/table/TableHeaderMenu', () => { const board = TestBlockFactory.createBoard() const view = TestBlockFactory.createBoardView(board) @@ -31,7 +21,7 @@ describe('components/table/TableHeaderMenu', () => { test('should match snapshot, title column', async () => { const onAutoSizeColumn = jest.fn() - const component = wrapProviders( + const component = wrapDNDIntl( { FetchMock.fn.mockReset() }) -const wrapIntl = (children: any) => {children} - describe('components/table/TableHeaderMenu', () => { const board = TestBlockFactory.createBoard() const view = TestBlockFactory.createBoardView(board) diff --git a/webapp/src/components/table/tableRow.test.tsx b/webapp/src/components/table/tableRow.test.tsx index f7f264178..d8da77b33 100644 --- a/webapp/src/components/table/tableRow.test.tsx +++ b/webapp/src/components/table/tableRow.test.tsx @@ -5,26 +5,16 @@ import React from 'react' import {Provider as ReduxProvider} from 'react-redux' import {render} from '@testing-library/react' import configureStore from 'redux-mock-store' + import '@testing-library/jest-dom' -import {IntlProvider} from 'react-intl' +import {wrapDNDIntl} from '../../testUtils' import 'isomorphic-fetch' -import {DndProvider} from 'react-dnd' -import {HTML5Backend} from 'react-dnd-html5-backend' - import {TestBlockFactory} from '../../test/testBlockFactory' import TableRow from './tableRow' -const wrapProviders = (children: any) => { - return ( - - {children} - - ) -} - describe('components/table/TableRow', () => { const board = TestBlockFactory.createBoard() const view = TestBlockFactory.createBoardView(board) @@ -55,7 +45,7 @@ describe('components/table/TableRow', () => { test('should match snapshot', async () => { const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( { test('should match snapshot, read-only', async () => { const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( { test('should match snapshot, isSelected', async () => { const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( { view.fields.hiddenOptionIds = [] const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( { view.fields.visiblePropertyIds = ['property1', 'property2'] const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( { view.fields.visiblePropertyIds = ['property1', 'property2'] const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( { FetchMock.fn.mockReset() }) -const wrapProviders = (children: any) => { - return ( - - {children} - - ) -} - describe('components/table/TableRows', () => { const board = TestBlockFactory.createBoard() const view = TestBlockFactory.createBoardView(board) @@ -71,7 +63,7 @@ describe('components/table/TableRows', () => { const addCard = jest.fn() const store = mockStore(state) - const component = wrapProviders( + const component = wrapDNDIntl( ( - {children} -) const board = TestBlockFactory.createBoard() const activeView = TestBlockFactory.createBoardView(board) const card = TestBlockFactory.createCard(board) diff --git a/webapp/src/components/workspaceSwitcher/workspaceOptions.test.tsx b/webapp/src/components/workspaceSwitcher/workspaceOptions.test.tsx index 6f17f6df3..77efc4c97 100644 --- a/webapp/src/components/workspaceSwitcher/workspaceOptions.test.tsx +++ b/webapp/src/components/workspaceSwitcher/workspaceOptions.test.tsx @@ -1,24 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react' - import configureStore from 'redux-mock-store' - -import {IntlProvider} from 'react-intl' import {Provider as ReduxProvider} from 'react-redux' - import {render} from '@testing-library/react' import {UserWorkspace} from '../../user' +import {wrapIntl} from '../../testUtils' import WorkspaceOptions from './workspaceOptions' -const wrapProviders = (children: any) => { - return ( - {children} - ) -} - describe('components/workspaceSwitcher/WorkspaceOptions', () => { const mockStore = configureStore([]) @@ -47,7 +38,7 @@ describe('components/workspaceSwitcher/WorkspaceOptions', () => { }, }) - const component = wrapProviders( + const component = wrapIntl( { @@ -68,7 +59,7 @@ describe('components/workspaceSwitcher/WorkspaceOptions', () => { }, }) - const component = wrapProviders( + const component = wrapIntl( { diff --git a/webapp/src/components/workspaceSwitcher/workspaceSwitcher.test.tsx b/webapp/src/components/workspaceSwitcher/workspaceSwitcher.test.tsx index c13f60178..f5731b66f 100644 --- a/webapp/src/components/workspaceSwitcher/workspaceSwitcher.test.tsx +++ b/webapp/src/components/workspaceSwitcher/workspaceSwitcher.test.tsx @@ -7,18 +7,12 @@ import {Provider as ReduxProvider} from 'react-redux' import {render} from '@testing-library/react' -import {IntlProvider} from 'react-intl' +import {wrapIntl} from '../../testUtils' import {UserWorkspace} from '../../user' import WorkspaceOptions from './workspaceOptions' -const wrapProviders = (children: any) => { - return ( - {children} - ) -} - describe('components/workspaceSwitcher/WorkspaceSwitcher', () => { const mockStore = configureStore([]) @@ -47,7 +41,7 @@ describe('components/workspaceSwitcher/WorkspaceSwitcher', () => { }, }) - const component = wrapProviders( + const component = wrapIntl( {}} @@ -67,7 +61,7 @@ describe('components/workspaceSwitcher/WorkspaceSwitcher', () => { }, }) - const component = wrapProviders( + const component = wrapIntl( {}} diff --git a/webapp/src/pages/dashboard/centerContent.test.tsx b/webapp/src/pages/dashboard/centerContent.test.tsx index 06875ec50..5658120b7 100644 --- a/webapp/src/pages/dashboard/centerContent.test.tsx +++ b/webapp/src/pages/dashboard/centerContent.test.tsx @@ -4,8 +4,6 @@ import React from 'react' import configureStore from 'redux-mock-store' import {Provider as ReduxProvider} from 'react-redux' -import {IntlProvider} from 'react-intl' - import {createMemoryHistory} from 'history' import {fireEvent, render} from '@testing-library/react' @@ -14,16 +12,12 @@ import userEvent from '@testing-library/user-event' import {Router} from 'react-router-dom' +import {wrapIntl} from '../../testUtils' + import {UserWorkspace} from '../../user' import DashboardCenterContent from './centerContent' -const wrapProviders = (children: any) => { - return ( - {children} - ) -} - describe('pages/dashboard/CenterContent', () => { const mockStore = configureStore([]) const workspace1: UserWorkspace = { @@ -51,7 +45,7 @@ describe('pages/dashboard/CenterContent', () => { }, }) - const component = wrapProviders( + const component = wrapIntl( , @@ -67,7 +61,7 @@ describe('pages/dashboard/CenterContent', () => { }, }) - const component = wrapProviders( + const component = wrapIntl( , @@ -86,7 +80,7 @@ describe('pages/dashboard/CenterContent', () => { }, }) - const component = wrapProviders( + const component = wrapIntl( , @@ -107,7 +101,7 @@ describe('pages/dashboard/CenterContent', () => { const history = createMemoryHistory() - const component = wrapProviders( + const component = wrapIntl( diff --git a/webapp/src/pages/dashboard/dashboardPage.test.tsx b/webapp/src/pages/dashboard/dashboardPage.test.tsx index f8a4ee84a..94dcb10e7 100644 --- a/webapp/src/pages/dashboard/dashboardPage.test.tsx +++ b/webapp/src/pages/dashboard/dashboardPage.test.tsx @@ -1,8 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react' -import {IntlProvider} from 'react-intl' - import {render} from '@testing-library/react' import configureStore from 'redux-mock-store' @@ -17,16 +15,10 @@ import {UserWorkspace} from '../../user' import {FetchMock} from '../../test/fetchMock' -import {mockMatchMedia} from '../../testUtils' +import {mockMatchMedia, wrapIntl} from '../../testUtils' import DashboardPage from './dashboardPage' -const wrapProviders = (children: any) => { - return ( - {children} - ) -} - beforeEach(() => { FetchMock.fn.mockReset() }) @@ -73,7 +65,7 @@ describe('pages/dashboard/DashboardPage', () => { const history = createMemoryHistory() - const component = wrapProviders( + const component = wrapIntl( diff --git a/webapp/src/testUtils.tsx b/webapp/src/testUtils.tsx index 3f81ad3a3..920deea48 100644 --- a/webapp/src/testUtils.tsx +++ b/webapp/src/testUtils.tsx @@ -2,10 +2,19 @@ // See LICENSE.txt for license information. import {IntlProvider} from 'react-intl' import React from 'react' +import {DndProvider} from 'react-dnd' +import {HTML5Backend} from 'react-dnd-html5-backend' import configureStore, {MockStoreEnhanced} from 'redux-mock-store' import {Middleware} from 'redux' export const wrapIntl = (children?: React.ReactNode): JSX.Element => {children} +export const wrapDNDIntl = (children?: React.ReactNode): JSX.Element => { + return ( + + {wrapIntl(children)} + + ) +} export function mockDOM(): void { window.focus = jest.fn() diff --git a/webapp/src/widgets/propertyMenu.test.tsx b/webapp/src/widgets/propertyMenu.test.tsx index 50de45670..9ba812a07 100644 --- a/webapp/src/widgets/propertyMenu.test.tsx +++ b/webapp/src/widgets/propertyMenu.test.tsx @@ -4,12 +4,11 @@ import React from 'react' import {fireEvent, render} from '@testing-library/react' import '@testing-library/jest-dom' -import {IntlProvider} from 'react-intl' + +import {wrapIntl} from '../testUtils' import PropertyMenu from './propertyMenu' -const wrapIntl = (children: any) => {children} - describe('widgets/PropertyMenu', () => { beforeEach(() => { // Quick fix to disregard console error when unmounting a component