gh-1360 Fix for tests using 'any' when wrapping components (#1374)
* fix for tests using any when wrapping components * update/cleanup use of test wrappers * fix up package Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
parent
7123311902
commit
0ac2fc0f62
27 changed files with 107 additions and 231 deletions
|
@ -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) => (
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
)
|
||||
const board = TestBlockFactory.createBoard()
|
||||
const card = TestBlockFactory.createCard(board)
|
||||
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
const board = TestBlockFactory.createBoard()
|
||||
const icon = '👍'
|
||||
|
||||
|
|
|
@ -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 (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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((
|
||||
<CardDetailContents
|
||||
id='test-id'
|
||||
card={card}
|
||||
|
@ -79,7 +67,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
|||
|
||||
test('should match snapshot with contents array', async () => {
|
||||
const contents = [TestBlockFactory.createDivider(card)]
|
||||
const component = wrapProviders((
|
||||
const component = wrapDNDIntl((
|
||||
<CardDetailContents
|
||||
id='test-id'
|
||||
card={card}
|
||||
|
@ -97,7 +85,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
|||
})
|
||||
|
||||
test('should match snapshot after onBlur triggers', async () => {
|
||||
const component = wrapProviders((
|
||||
const component = wrapDNDIntl((
|
||||
<CardDetailContents
|
||||
id='test-id'
|
||||
card={card}
|
||||
|
@ -144,7 +132,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
|||
|
||||
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((
|
||||
<CardDetailContents
|
||||
id='test-id'
|
||||
card={card}
|
||||
|
@ -164,7 +152,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
|||
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((
|
||||
<CardDetailContents
|
||||
id='test-id'
|
||||
card={card}
|
||||
|
@ -193,7 +181,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
|||
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((
|
||||
<CardDetailContents
|
||||
id='test-id'
|
||||
card={card}
|
||||
|
@ -222,7 +210,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
|||
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((
|
||||
<CardDetailContents
|
||||
id='test-id'
|
||||
card={card}
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
import React from 'react'
|
||||
|
||||
import {fireEvent, render} from '@testing-library/react'
|
||||
import {IntlProvider} from 'react-intl'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
||||
import {wrapIntl} from '../../testUtils'
|
||||
|
||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||
import {FetchMock} from '../../test/fetchMock'
|
||||
|
||||
|
@ -19,8 +20,6 @@ beforeEach(() => {
|
|||
FetchMock.fn.mockReset()
|
||||
})
|
||||
|
||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
|
||||
describe('components/cardDetail/CardDetailProperties', () => {
|
||||
const board = TestBlockFactory.createBoard()
|
||||
board.fields.cardProperties = [
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
|
||||
describe('components/content/CheckboxElement', () => {
|
||||
const defaultBlock: ContentBlock = {
|
||||
id: 'test-id',
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
import GlobalHeader from './globalHeader'
|
||||
|
||||
describe('components/sidebar/GlobalHeader', () => {
|
||||
const mockStore = configureStore([])
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
import GlobalHeaderSettingsMenu from './globalHeaderSettingsMenu'
|
||||
|
||||
describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
|
||||
const mockStore = configureStore([])
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
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))
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
|
||||
describe('componnets/properties/lastModifiedAt', () => {
|
||||
test('should match snapshot', () => {
|
||||
const card = createCard()
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
import UserProperty from './user'
|
||||
|
||||
describe('components/properties/user', () => {
|
||||
const mockStore = configureStore([])
|
||||
|
|
|
@ -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 (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<PropertyValueElement
|
||||
board={board}
|
||||
readOnly={false}
|
||||
|
@ -49,7 +40,7 @@ describe('components/propertyValueElement', () => {
|
|||
|
||||
test('should match snapshot, select, read-only', async () => {
|
||||
const propertyTemplate = board.fields.cardProperties.find((p) => p.id === 'property1')
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<PropertyValueElement
|
||||
board={board}
|
||||
readOnly={true}
|
||||
|
@ -83,7 +74,7 @@ describe('components/propertyValueElement', () => {
|
|||
options,
|
||||
}
|
||||
card.fields.properties.multiSelect = ['ms1', 'ms2']
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<PropertyValueElement
|
||||
board={board}
|
||||
readOnly={false}
|
||||
|
@ -108,7 +99,7 @@ describe('components/propertyValueElement', () => {
|
|||
}
|
||||
card.fields.properties.property_url = ['http://localhost']
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<PropertyValueElement
|
||||
board={board}
|
||||
readOnly={false}
|
||||
|
@ -133,7 +124,7 @@ describe('components/propertyValueElement', () => {
|
|||
}
|
||||
card.fields.properties.property_url = ['http://localhost']
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<PropertyValueElement
|
||||
board={board}
|
||||
readOnly={false}
|
||||
|
@ -158,7 +149,7 @@ describe('components/propertyValueElement', () => {
|
|||
}
|
||||
card.fields.properties.person = ['value1', 'value2']
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<PropertyValueElement
|
||||
board={board}
|
||||
readOnly={false}
|
||||
|
@ -183,7 +174,7 @@ describe('components/propertyValueElement', () => {
|
|||
}
|
||||
card.fields.properties.date = ['invalid date']
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<PropertyValueElement
|
||||
board={board}
|
||||
readOnly={false}
|
||||
|
|
|
@ -8,23 +8,14 @@ import {Provider as ReduxProvider} from 'react-redux'
|
|||
import {Router} from 'react-router-dom'
|
||||
|
||||
import {render} from '@testing-library/react'
|
||||
|
||||
import {IntlProvider} from 'react-intl'
|
||||
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
||||
import {UserWorkspace} from '../../user'
|
||||
|
||||
import {mockMatchMedia} from '../../testUtils'
|
||||
import {mockMatchMedia, wrapIntl} from '../../testUtils'
|
||||
|
||||
import Sidebar from './sidebar'
|
||||
|
||||
const wrapProviders = (children: any) => {
|
||||
return (
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
)
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
mockMatchMedia({matches: true})
|
||||
})
|
||||
|
@ -67,7 +58,7 @@ describe('components/sidebarSidebar', () => {
|
|||
|
||||
const history = createMemoryHistory()
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Router history={history}>
|
||||
<Sidebar isDashboard={true}/>
|
||||
|
@ -105,7 +96,7 @@ describe('components/sidebarSidebar', () => {
|
|||
|
||||
const history = createMemoryHistory()
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Router history={history}>
|
||||
<Sidebar/>
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
|
||||
describe('components/sidebar/SidebarSettingsMenu', () => {
|
||||
const mockStore = configureStore([])
|
||||
let store = mockStore({})
|
||||
|
|
|
@ -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 (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<CalculationRow
|
||||
board={board}
|
||||
cards={[card, card2]}
|
||||
|
@ -88,7 +77,7 @@ describe('components/table/calculation/CalculationRow', () => {
|
|||
property_4: 'countUniqueValue',
|
||||
}
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<CalculationRow
|
||||
board={board}
|
||||
cards={[card, card2]}
|
||||
|
|
|
@ -6,13 +6,9 @@ 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 'isomorphic-fetch'
|
||||
|
||||
import {DndProvider} from 'react-dnd'
|
||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
||||
|
||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||
import {FetchMock} from '../../test/fetchMock'
|
||||
import {BoardView} from '../../blocks/boardView'
|
||||
|
@ -21,6 +17,8 @@ import {IUser} from '../../user'
|
|||
|
||||
import {Utils} from '../../utils'
|
||||
|
||||
import {wrapDNDIntl} from '../../testUtils'
|
||||
|
||||
import Table from './table'
|
||||
|
||||
global.fetch = FetchMock.fn
|
||||
|
@ -29,14 +27,6 @@ beforeEach(() => {
|
|||
FetchMock.fn.mockReset()
|
||||
})
|
||||
|
||||
const wrapProviders = (children: any) => {
|
||||
return (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<ReduxProvider store={store}>
|
||||
<Table
|
||||
board={board}
|
||||
|
@ -108,7 +98,7 @@ describe('components/table/Table', () => {
|
|||
const mockStore = configureStore([])
|
||||
const store = mockStore(state)
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Table
|
||||
board={board}
|
||||
|
@ -137,7 +127,7 @@ describe('components/table/Table', () => {
|
|||
const mockStore = configureStore([])
|
||||
const store = mockStore(state)
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Table
|
||||
board={board}
|
||||
|
@ -222,7 +212,7 @@ describe('components/table/Table extended', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Table
|
||||
board={board}
|
||||
|
@ -301,7 +291,7 @@ describe('components/table/Table extended', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Table
|
||||
board={board}
|
||||
|
@ -358,7 +348,7 @@ describe('components/table/Table extended', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Table
|
||||
board={board}
|
||||
|
@ -442,7 +432,7 @@ describe('components/table/Table extended', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Table
|
||||
board={board}
|
||||
|
|
|
@ -4,29 +4,19 @@
|
|||
import React from 'react'
|
||||
import {fireEvent, render} from '@testing-library/react'
|
||||
import '@testing-library/jest-dom'
|
||||
import {IntlProvider} from 'react-intl'
|
||||
|
||||
import 'isomorphic-fetch'
|
||||
|
||||
import {DndProvider} from 'react-dnd'
|
||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
||||
|
||||
import {act} from 'react-dom/test-utils'
|
||||
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
||||
import {wrapDNDIntl} from '../../testUtils'
|
||||
|
||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||
|
||||
import TableGroupHeaderRowElement from './tableGroupHeaderRow'
|
||||
|
||||
const wrapProviders = (children: any) => {
|
||||
return (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<TableGroupHeaderRowElement
|
||||
board={board}
|
||||
activeView={view}
|
||||
|
@ -75,7 +65,7 @@ test('should match snapshot, no groups', async () => {
|
|||
})
|
||||
|
||||
test('should match snapshot with Group', async () => {
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<TableGroupHeaderRowElement
|
||||
board={board}
|
||||
activeView={view}
|
||||
|
@ -92,7 +82,7 @@ test('should match snapshot with Group', async () => {
|
|||
})
|
||||
|
||||
test('should match snapshot on read only', async () => {
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<TableGroupHeaderRowElement
|
||||
board={board}
|
||||
activeView={view}
|
||||
|
@ -114,7 +104,7 @@ test('should match snapshot, hide group', async () => {
|
|||
const collapsedOptionsView = TestBlockFactory.createBoardView(board)
|
||||
collapsedOptionsView.fields.collapsedOptionIds = [boardTreeGroup.option.id]
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<TableGroupHeaderRowElement
|
||||
board={board}
|
||||
activeView={collapsedOptionsView}
|
||||
|
@ -141,7 +131,7 @@ test('should match snapshot, hide group', async () => {
|
|||
test('should match snapshot, add new', async () => {
|
||||
const addNew = jest.fn()
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<TableGroupHeaderRowElement
|
||||
board={board}
|
||||
activeView={view}
|
||||
|
@ -167,7 +157,7 @@ test('should match snapshot, add new', async () => {
|
|||
})
|
||||
|
||||
test('should match snapshot, edit title', async () => {
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<TableGroupHeaderRowElement
|
||||
board={board}
|
||||
activeView={view}
|
||||
|
|
|
@ -4,24 +4,14 @@
|
|||
import React from 'react'
|
||||
import {render} from '@testing-library/react'
|
||||
import '@testing-library/jest-dom'
|
||||
import {IntlProvider} from 'react-intl'
|
||||
|
||||
import 'isomorphic-fetch'
|
||||
import {DndProvider} from 'react-dnd'
|
||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
||||
import {wrapDNDIntl} from '../../testUtils'
|
||||
|
||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||
|
||||
import TableHeader from './tableHeader'
|
||||
|
||||
const wrapProviders = (children: any) => {
|
||||
return (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<TableHeader
|
||||
readonly={false}
|
||||
sorted={'none'}
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
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 'isomorphic-fetch'
|
||||
|
||||
|
@ -33,8 +34,6 @@ beforeEach(() => {
|
|||
FetchMock.fn.mockReset()
|
||||
})
|
||||
|
||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
|
||||
describe('components/table/TableHeaderMenu', () => {
|
||||
const board = TestBlockFactory.createBoard()
|
||||
const view = TestBlockFactory.createBoardView(board)
|
||||
|
|
|
@ -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 (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<ReduxProvider store={store}>
|
||||
<TableRow
|
||||
board={board}
|
||||
|
@ -80,7 +70,7 @@ describe('components/table/TableRow', () => {
|
|||
|
||||
test('should match snapshot, read-only', async () => {
|
||||
const store = mockStore(state)
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<TableRow
|
||||
board={board}
|
||||
|
@ -105,7 +95,7 @@ describe('components/table/TableRow', () => {
|
|||
|
||||
test('should match snapshot, isSelected', async () => {
|
||||
const store = mockStore(state)
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<TableRow
|
||||
board={board}
|
||||
|
@ -133,7 +123,7 @@ describe('components/table/TableRow', () => {
|
|||
view.fields.hiddenOptionIds = []
|
||||
|
||||
const store = mockStore(state)
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<TableRow
|
||||
board={board}
|
||||
|
@ -160,7 +150,7 @@ describe('components/table/TableRow', () => {
|
|||
view.fields.visiblePropertyIds = ['property1', 'property2']
|
||||
|
||||
const store = mockStore(state)
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<TableRow
|
||||
board={board}
|
||||
|
@ -186,7 +176,7 @@ describe('components/table/TableRow', () => {
|
|||
view.fields.visiblePropertyIds = ['property1', 'property2']
|
||||
|
||||
const store = mockStore(state)
|
||||
const component = wrapProviders(
|
||||
const component = wrapDNDIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<TableRow
|
||||
board={board}
|
||||
|
|
|
@ -6,7 +6,6 @@ import {Provider as ReduxProvider} from 'react-redux'
|
|||
import {fireEvent, render} from '@testing-library/react'
|
||||
import configureStore from 'redux-mock-store'
|
||||
import '@testing-library/jest-dom'
|
||||
import {IntlProvider} from 'react-intl'
|
||||
|
||||
import 'isomorphic-fetch'
|
||||
|
||||
|
@ -19,6 +18,7 @@ import userEvent from '@testing-library/user-event'
|
|||
|
||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||
import {FetchMock} from '../../test/fetchMock'
|
||||
import {wrapDNDIntl} from '../../testUtils'
|
||||
|
||||
import TableRows from './tableRows'
|
||||
|
||||
|
@ -28,14 +28,6 @@ beforeEach(() => {
|
|||
FetchMock.fn.mockReset()
|
||||
})
|
||||
|
||||
const wrapProviders = (children: any) => {
|
||||
return (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<ReduxProvider store={store}>
|
||||
<TableRows
|
||||
board={board}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// 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} from '@testing-library/react'
|
||||
import {Provider as ReduxProvider} from 'react-redux'
|
||||
import configureStore from 'redux-mock-store'
|
||||
|
@ -9,15 +9,12 @@ import configureStore from 'redux-mock-store'
|
|||
import '@testing-library/jest-dom'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
||||
import {IntlProvider} from 'react-intl'
|
||||
import {wrapIntl} from '../../testUtils'
|
||||
|
||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||
|
||||
import ViewHeaderActionsMenu from './viewHeaderActionsMenu'
|
||||
|
||||
const wrapIntl = (children: ReactElement) => (
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
)
|
||||
const board = TestBlockFactory.createBoard()
|
||||
const activeView = TestBlockFactory.createBoardView(board)
|
||||
const card = TestBlockFactory.createCard(board)
|
||||
|
|
|
@ -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 (
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
)
|
||||
}
|
||||
|
||||
describe('components/workspaceSwitcher/WorkspaceOptions', () => {
|
||||
const mockStore = configureStore([])
|
||||
|
||||
|
@ -47,7 +38,7 @@ describe('components/workspaceSwitcher/WorkspaceOptions', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<WorkspaceOptions
|
||||
onChange={() => {
|
||||
|
@ -68,7 +59,7 @@ describe('components/workspaceSwitcher/WorkspaceOptions', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<WorkspaceOptions
|
||||
onChange={() => {
|
||||
|
|
|
@ -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 (
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
)
|
||||
}
|
||||
|
||||
describe('components/workspaceSwitcher/WorkspaceSwitcher', () => {
|
||||
const mockStore = configureStore([])
|
||||
|
||||
|
@ -47,7 +41,7 @@ describe('components/workspaceSwitcher/WorkspaceSwitcher', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<WorkspaceOptions
|
||||
onChange={() => {}}
|
||||
|
@ -67,7 +61,7 @@ describe('components/workspaceSwitcher/WorkspaceSwitcher', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<WorkspaceOptions
|
||||
onChange={() => {}}
|
||||
|
|
|
@ -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 (
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
)
|
||||
}
|
||||
|
||||
describe('pages/dashboard/CenterContent', () => {
|
||||
const mockStore = configureStore([])
|
||||
const workspace1: UserWorkspace = {
|
||||
|
@ -51,7 +45,7 @@ describe('pages/dashboard/CenterContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<DashboardCenterContent/>
|
||||
</ReduxProvider>,
|
||||
|
@ -67,7 +61,7 @@ describe('pages/dashboard/CenterContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<DashboardCenterContent/>
|
||||
</ReduxProvider>,
|
||||
|
@ -86,7 +80,7 @@ describe('pages/dashboard/CenterContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<DashboardCenterContent/>
|
||||
</ReduxProvider>,
|
||||
|
@ -107,7 +101,7 @@ describe('pages/dashboard/CenterContent', () => {
|
|||
|
||||
const history = createMemoryHistory()
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<Router history={history}>
|
||||
<ReduxProvider store={store}>
|
||||
<DashboardCenterContent/>
|
||||
|
|
|
@ -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 (
|
||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
||||
)
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
FetchMock.fn.mockReset()
|
||||
})
|
||||
|
@ -73,7 +65,7 @@ describe('pages/dashboard/DashboardPage', () => {
|
|||
|
||||
const history = createMemoryHistory()
|
||||
|
||||
const component = wrapProviders(
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<Router history={history}>
|
||||
<DashboardPage/>
|
||||
|
|
|
@ -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 => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
export const wrapDNDIntl = (children?: React.ReactNode): JSX.Element => {
|
||||
return (
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
{wrapIntl(children)}
|
||||
</DndProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export function mockDOM(): void {
|
||||
window.focus = jest.fn()
|
||||
|
|
|
@ -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) => <IntlProvider locale='en'>{children}</IntlProvider>
|
||||
|
||||
describe('widgets/PropertyMenu', () => {
|
||||
beforeEach(() => {
|
||||
// Quick fix to disregard console error when unmounting a component
|
||||
|
|
Loading…
Reference in a new issue