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.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {ReactElement} from 'react'
|
import React from 'react'
|
||||||
import {render, screen, waitFor} from '@testing-library/react'
|
import {render, screen, waitFor} from '@testing-library/react'
|
||||||
|
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import {mocked} from 'ts-jest/utils'
|
import {mocked} from 'ts-jest/utils'
|
||||||
|
|
||||||
|
@ -15,6 +14,8 @@ import mutator from '../mutator'
|
||||||
|
|
||||||
import {TestBlockFactory} from '../test/testBlockFactory'
|
import {TestBlockFactory} from '../test/testBlockFactory'
|
||||||
|
|
||||||
|
import {wrapIntl} from '../testUtils'
|
||||||
|
|
||||||
import AddContentMenuItem from './addContentMenuItem'
|
import AddContentMenuItem from './addContentMenuItem'
|
||||||
|
|
||||||
import './content/textElement'
|
import './content/textElement'
|
||||||
|
@ -22,9 +23,6 @@ import './content/imageElement'
|
||||||
import './content/dividerElement'
|
import './content/dividerElement'
|
||||||
import './content/checkboxElement'
|
import './content/checkboxElement'
|
||||||
|
|
||||||
const wrapIntl = (children: ReactElement) => (
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
)
|
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const card = TestBlockFactory.createCard(board)
|
const card = TestBlockFactory.createCard(board)
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {ReactElement} from 'react'
|
import React from 'react'
|
||||||
import {fireEvent, render, screen} from '@testing-library/react'
|
import {fireEvent, render, screen} from '@testing-library/react'
|
||||||
|
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
|
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import {mocked} from 'ts-jest/utils'
|
import {mocked} from 'ts-jest/utils'
|
||||||
|
|
||||||
import mutator from '../mutator'
|
import mutator from '../mutator'
|
||||||
|
|
||||||
|
import {wrapIntl} from '../testUtils'
|
||||||
|
|
||||||
import {TestBlockFactory} from '../test/testBlockFactory'
|
import {TestBlockFactory} from '../test/testBlockFactory'
|
||||||
|
|
||||||
import BlockIconSelector from './blockIconSelector'
|
import BlockIconSelector from './blockIconSelector'
|
||||||
|
|
||||||
const wrapIntl = (children: ReactElement) => <IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const icon = '👍'
|
const icon = '👍'
|
||||||
|
|
||||||
|
|
|
@ -4,26 +4,14 @@ import React from 'react'
|
||||||
|
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
import {fireEvent, render} from '@testing-library/react'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
import {act} from 'react-dom/test-utils'
|
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 {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
|
|
||||||
import {mockDOM} from '../../testUtils'
|
import {mockDOM, wrapDNDIntl} from '../../testUtils'
|
||||||
|
|
||||||
import CardDetailContents from './cardDetailContents'
|
import CardDetailContents from './cardDetailContents'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
global.fetch = jest.fn()
|
global.fetch = jest.fn()
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
@ -60,7 +48,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
||||||
const card = TestBlockFactory.createCard(board)
|
const card = TestBlockFactory.createCard(board)
|
||||||
|
|
||||||
test('should match snapshot', async () => {
|
test('should match snapshot', async () => {
|
||||||
const component = wrapProviders((
|
const component = wrapDNDIntl((
|
||||||
<CardDetailContents
|
<CardDetailContents
|
||||||
id='test-id'
|
id='test-id'
|
||||||
card={card}
|
card={card}
|
||||||
|
@ -79,7 +67,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
||||||
|
|
||||||
test('should match snapshot with contents array', async () => {
|
test('should match snapshot with contents array', async () => {
|
||||||
const contents = [TestBlockFactory.createDivider(card)]
|
const contents = [TestBlockFactory.createDivider(card)]
|
||||||
const component = wrapProviders((
|
const component = wrapDNDIntl((
|
||||||
<CardDetailContents
|
<CardDetailContents
|
||||||
id='test-id'
|
id='test-id'
|
||||||
card={card}
|
card={card}
|
||||||
|
@ -97,7 +85,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should match snapshot after onBlur triggers', async () => {
|
test('should match snapshot after onBlur triggers', async () => {
|
||||||
const component = wrapProviders((
|
const component = wrapDNDIntl((
|
||||||
<CardDetailContents
|
<CardDetailContents
|
||||||
id='test-id'
|
id='test-id'
|
||||||
card={card}
|
card={card}
|
||||||
|
@ -144,7 +132,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
||||||
|
|
||||||
test('should match snapshot with contents array that has array inside it', async () => {
|
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 contents = [TestBlockFactory.createDivider(card), [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)]]
|
||||||
const component = wrapProviders((
|
const component = wrapDNDIntl((
|
||||||
<CardDetailContents
|
<CardDetailContents
|
||||||
id='test-id'
|
id='test-id'
|
||||||
card={card}
|
card={card}
|
||||||
|
@ -164,7 +152,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
||||||
test('should match snapshot after drag and drop event', async () => {
|
test('should match snapshot after drag and drop event', async () => {
|
||||||
const contents = [TestBlockFactory.createDivider(card), [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)]]
|
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))
|
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
|
<CardDetailContents
|
||||||
id='test-id'
|
id='test-id'
|
||||||
card={card}
|
card={card}
|
||||||
|
@ -193,7 +181,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
||||||
test('should match snapshot after drag and drop event 2', async () => {
|
test('should match snapshot after drag and drop event 2', async () => {
|
||||||
const contents = [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)]
|
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))
|
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
|
<CardDetailContents
|
||||||
id='test-id'
|
id='test-id'
|
||||||
card={card}
|
card={card}
|
||||||
|
@ -222,7 +210,7 @@ describe('components/cardDetail/cardDetailContents', () => {
|
||||||
test('should match snapshot after drag and drop event 3', async () => {
|
test('should match snapshot after drag and drop event 3', async () => {
|
||||||
const contents = [TestBlockFactory.createDivider(card), TestBlockFactory.createDivider(card)]
|
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))
|
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
|
<CardDetailContents
|
||||||
id='test-id'
|
id='test-id'
|
||||||
card={card}
|
card={card}
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
import {fireEvent, render} from '@testing-library/react'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
|
|
||||||
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
import {FetchMock} from '../../test/fetchMock'
|
import {FetchMock} from '../../test/fetchMock'
|
||||||
|
|
||||||
|
@ -19,8 +20,6 @@ beforeEach(() => {
|
||||||
FetchMock.fn.mockReset()
|
FetchMock.fn.mockReset()
|
||||||
})
|
})
|
||||||
|
|
||||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
|
|
||||||
describe('components/cardDetail/CardDetailProperties', () => {
|
describe('components/cardDetail/CardDetailProperties', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
board.fields.cardProperties = [
|
board.fields.cardProperties = [
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
import {fireEvent, render} from '@testing-library/react'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import {ContentBlock} from '../../blocks/contentBlock'
|
import {ContentBlock} from '../../blocks/contentBlock'
|
||||||
|
|
||||||
|
@ -12,8 +13,6 @@ import CheckboxElement from './checkboxElement'
|
||||||
|
|
||||||
const fetchMock = require('fetch-mock-jest')
|
const fetchMock = require('fetch-mock-jest')
|
||||||
|
|
||||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
|
|
||||||
describe('components/content/CheckboxElement', () => {
|
describe('components/content/CheckboxElement', () => {
|
||||||
const defaultBlock: ContentBlock = {
|
const defaultBlock: ContentBlock = {
|
||||||
id: 'test-id',
|
id: 'test-id',
|
||||||
|
|
|
@ -6,13 +6,11 @@ import {Provider as ReduxProvider} from 'react-redux'
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import configureStore from 'redux-mock-store'
|
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', () => {
|
describe('components/sidebar/GlobalHeader', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
|
|
|
@ -6,14 +6,12 @@ import {Provider as ReduxProvider} from 'react-redux'
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
import configureStore from 'redux-mock-store'
|
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', () => {
|
describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
|
|
||||||
import '@testing-library/jest-dom'
|
|
||||||
import {IntlProvider} from 'react-intl'
|
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.
|
// create Dates for specific days for this year.
|
||||||
const June15 = new Date(Date.UTC(new Date().getFullYear(), 5, 15, 12))
|
const June15 = new Date(Date.UTC(new Date().getFullYear(), 5, 15, 12))
|
||||||
|
|
|
@ -3,15 +3,14 @@
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
import {wrapIntl} from '../../../testUtils'
|
||||||
|
|
||||||
import {createCard} from '../../../blocks/card'
|
import {createCard} from '../../../blocks/card'
|
||||||
import {createCommentBlock} from '../../../blocks/commentBlock'
|
import {createCommentBlock} from '../../../blocks/commentBlock'
|
||||||
|
|
||||||
import LastModifiedAt from './lastModifiedAt'
|
import LastModifiedAt from './lastModifiedAt'
|
||||||
|
|
||||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
|
|
||||||
describe('componnets/properties/lastModifiedAt', () => {
|
describe('componnets/properties/lastModifiedAt', () => {
|
||||||
test('should match snapshot', () => {
|
test('should match snapshot', () => {
|
||||||
const card = createCard()
|
const card = createCard()
|
||||||
|
|
|
@ -3,17 +3,18 @@
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Provider as ReduxProvider} from 'react-redux'
|
import {Provider as ReduxProvider} from 'react-redux'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
import {render, waitFor} from '@testing-library/react'
|
import {render, waitFor} from '@testing-library/react'
|
||||||
|
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
|
|
||||||
import {act} from 'react-dom/test-utils'
|
import {act} from 'react-dom/test-utils'
|
||||||
|
|
||||||
import userEvent from '@testing-library/user-event'
|
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', () => {
|
describe('components/properties/user', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
import {wrapDNDIntl} from '../testUtils'
|
||||||
|
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
import {DndProvider} from 'react-dnd'
|
|
||||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
|
||||||
|
|
||||||
import {IPropertyTemplate, IPropertyOption} from '../blocks/board'
|
import {IPropertyTemplate, IPropertyOption} from '../blocks/board'
|
||||||
|
|
||||||
|
@ -16,14 +15,6 @@ import {TestBlockFactory} from '../test/testBlockFactory'
|
||||||
|
|
||||||
import PropertyValueElement from './propertyValueElement'
|
import PropertyValueElement from './propertyValueElement'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/propertyValueElement', () => {
|
describe('components/propertyValueElement', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const card = TestBlockFactory.createCard(board)
|
const card = TestBlockFactory.createCard(board)
|
||||||
|
@ -31,7 +22,7 @@ describe('components/propertyValueElement', () => {
|
||||||
|
|
||||||
test('should match snapshot, select', async () => {
|
test('should match snapshot, select', async () => {
|
||||||
const propertyTemplate = board.fields.cardProperties.find((p) => p.id === 'property1')
|
const propertyTemplate = board.fields.cardProperties.find((p) => p.id === 'property1')
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<PropertyValueElement
|
<PropertyValueElement
|
||||||
board={board}
|
board={board}
|
||||||
readOnly={false}
|
readOnly={false}
|
||||||
|
@ -49,7 +40,7 @@ describe('components/propertyValueElement', () => {
|
||||||
|
|
||||||
test('should match snapshot, select, read-only', async () => {
|
test('should match snapshot, select, read-only', async () => {
|
||||||
const propertyTemplate = board.fields.cardProperties.find((p) => p.id === 'property1')
|
const propertyTemplate = board.fields.cardProperties.find((p) => p.id === 'property1')
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<PropertyValueElement
|
<PropertyValueElement
|
||||||
board={board}
|
board={board}
|
||||||
readOnly={true}
|
readOnly={true}
|
||||||
|
@ -83,7 +74,7 @@ describe('components/propertyValueElement', () => {
|
||||||
options,
|
options,
|
||||||
}
|
}
|
||||||
card.fields.properties.multiSelect = ['ms1', 'ms2']
|
card.fields.properties.multiSelect = ['ms1', 'ms2']
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<PropertyValueElement
|
<PropertyValueElement
|
||||||
board={board}
|
board={board}
|
||||||
readOnly={false}
|
readOnly={false}
|
||||||
|
@ -108,7 +99,7 @@ describe('components/propertyValueElement', () => {
|
||||||
}
|
}
|
||||||
card.fields.properties.property_url = ['http://localhost']
|
card.fields.properties.property_url = ['http://localhost']
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<PropertyValueElement
|
<PropertyValueElement
|
||||||
board={board}
|
board={board}
|
||||||
readOnly={false}
|
readOnly={false}
|
||||||
|
@ -133,7 +124,7 @@ describe('components/propertyValueElement', () => {
|
||||||
}
|
}
|
||||||
card.fields.properties.property_url = ['http://localhost']
|
card.fields.properties.property_url = ['http://localhost']
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<PropertyValueElement
|
<PropertyValueElement
|
||||||
board={board}
|
board={board}
|
||||||
readOnly={false}
|
readOnly={false}
|
||||||
|
@ -158,7 +149,7 @@ describe('components/propertyValueElement', () => {
|
||||||
}
|
}
|
||||||
card.fields.properties.person = ['value1', 'value2']
|
card.fields.properties.person = ['value1', 'value2']
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<PropertyValueElement
|
<PropertyValueElement
|
||||||
board={board}
|
board={board}
|
||||||
readOnly={false}
|
readOnly={false}
|
||||||
|
@ -183,7 +174,7 @@ describe('components/propertyValueElement', () => {
|
||||||
}
|
}
|
||||||
card.fields.properties.date = ['invalid date']
|
card.fields.properties.date = ['invalid date']
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<PropertyValueElement
|
<PropertyValueElement
|
||||||
board={board}
|
board={board}
|
||||||
readOnly={false}
|
readOnly={false}
|
||||||
|
|
|
@ -8,23 +8,14 @@ import {Provider as ReduxProvider} from 'react-redux'
|
||||||
import {Router} from 'react-router-dom'
|
import {Router} from 'react-router-dom'
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
|
|
||||||
import {UserWorkspace} from '../../user'
|
import {UserWorkspace} from '../../user'
|
||||||
|
|
||||||
import {mockMatchMedia} from '../../testUtils'
|
import {mockMatchMedia, wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import Sidebar from './sidebar'
|
import Sidebar from './sidebar'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
mockMatchMedia({matches: true})
|
mockMatchMedia({matches: true})
|
||||||
})
|
})
|
||||||
|
@ -67,7 +58,7 @@ describe('components/sidebarSidebar', () => {
|
||||||
|
|
||||||
const history = createMemoryHistory()
|
const history = createMemoryHistory()
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
<Sidebar isDashboard={true}/>
|
<Sidebar isDashboard={true}/>
|
||||||
|
@ -105,7 +96,7 @@ describe('components/sidebarSidebar', () => {
|
||||||
|
|
||||||
const history = createMemoryHistory()
|
const history = createMemoryHistory()
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
<Sidebar/>
|
<Sidebar/>
|
||||||
|
|
|
@ -6,17 +6,15 @@ import {Provider as ReduxProvider} from 'react-redux'
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
|
|
||||||
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import {defaultThemeName} from '../../theme'
|
import {defaultThemeName} from '../../theme'
|
||||||
|
|
||||||
import SidebarSettingsMenu from './sidebarSettingsMenu'
|
import SidebarSettingsMenu from './sidebarSettingsMenu'
|
||||||
|
|
||||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
|
|
||||||
describe('components/sidebar/SidebarSettingsMenu', () => {
|
describe('components/sidebar/SidebarSettingsMenu', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
let store = mockStore({})
|
let store = mockStore({})
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// 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 React from 'react'
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
@ -12,6 +8,7 @@ import '@testing-library/jest-dom'
|
||||||
import {TestBlockFactory} from '../../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../../test/testBlockFactory'
|
||||||
import {FetchMock} from '../../../test/fetchMock'
|
import {FetchMock} from '../../../test/fetchMock'
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
|
import {wrapDNDIntl} from '../../../testUtils'
|
||||||
|
|
||||||
import CalculationRow from './calculationRow'
|
import CalculationRow from './calculationRow'
|
||||||
|
|
||||||
|
@ -21,14 +18,6 @@ beforeEach(() => {
|
||||||
FetchMock.fn.mockReset()
|
FetchMock.fn.mockReset()
|
||||||
})
|
})
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/table/calculation/CalculationRow', () => {
|
describe('components/table/calculation/CalculationRow', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
board.fields.cardProperties.push({
|
board.fields.cardProperties.push({
|
||||||
|
@ -66,7 +55,7 @@ describe('components/table/calculation/CalculationRow', () => {
|
||||||
test('should render three calculation elements', async () => {
|
test('should render three calculation elements', async () => {
|
||||||
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify([board, view, card])))
|
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify([board, view, card])))
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<CalculationRow
|
<CalculationRow
|
||||||
board={board}
|
board={board}
|
||||||
cards={[card, card2]}
|
cards={[card, card2]}
|
||||||
|
@ -88,7 +77,7 @@ describe('components/table/calculation/CalculationRow', () => {
|
||||||
property_4: 'countUniqueValue',
|
property_4: 'countUniqueValue',
|
||||||
}
|
}
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<CalculationRow
|
<CalculationRow
|
||||||
board={board}
|
board={board}
|
||||||
cards={[card, card2]}
|
cards={[card, card2]}
|
||||||
|
|
|
@ -6,13 +6,9 @@ import {Provider as ReduxProvider} from 'react-redux'
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
|
|
||||||
import {DndProvider} from 'react-dnd'
|
|
||||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
|
||||||
|
|
||||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
import {FetchMock} from '../../test/fetchMock'
|
import {FetchMock} from '../../test/fetchMock'
|
||||||
import {BoardView} from '../../blocks/boardView'
|
import {BoardView} from '../../blocks/boardView'
|
||||||
|
@ -21,6 +17,8 @@ import {IUser} from '../../user'
|
||||||
|
|
||||||
import {Utils} from '../../utils'
|
import {Utils} from '../../utils'
|
||||||
|
|
||||||
|
import {wrapDNDIntl} from '../../testUtils'
|
||||||
|
|
||||||
import Table from './table'
|
import Table from './table'
|
||||||
|
|
||||||
global.fetch = FetchMock.fn
|
global.fetch = FetchMock.fn
|
||||||
|
@ -29,14 +27,6 @@ beforeEach(() => {
|
||||||
FetchMock.fn.mockReset()
|
FetchMock.fn.mockReset()
|
||||||
})
|
})
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/table/Table', () => {
|
describe('components/table/Table', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const view = TestBlockFactory.createBoardView(board)
|
const view = TestBlockFactory.createBoardView(board)
|
||||||
|
@ -80,7 +70,7 @@ describe('components/table/Table', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Table
|
<Table
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -108,7 +98,7 @@ describe('components/table/Table', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Table
|
<Table
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -137,7 +127,7 @@ describe('components/table/Table', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Table
|
<Table
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -222,7 +212,7 @@ describe('components/table/Table extended', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Table
|
<Table
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -301,7 +291,7 @@ describe('components/table/Table extended', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Table
|
<Table
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -358,7 +348,7 @@ describe('components/table/Table extended', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Table
|
<Table
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -442,7 +432,7 @@ describe('components/table/Table extended', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Table
|
<Table
|
||||||
board={board}
|
board={board}
|
||||||
|
|
|
@ -4,29 +4,19 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
import {fireEvent, render} from '@testing-library/react'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
|
|
||||||
import {DndProvider} from 'react-dnd'
|
|
||||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
|
||||||
|
|
||||||
import {act} from 'react-dom/test-utils'
|
import {act} from 'react-dom/test-utils'
|
||||||
|
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
|
|
||||||
|
import {wrapDNDIntl} from '../../testUtils'
|
||||||
|
|
||||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
|
|
||||||
import TableGroupHeaderRowElement from './tableGroupHeaderRow'
|
import TableGroupHeaderRowElement from './tableGroupHeaderRow'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const view = TestBlockFactory.createBoardView(board)
|
const view = TestBlockFactory.createBoardView(board)
|
||||||
|
|
||||||
|
@ -52,7 +42,7 @@ const boardTreeGroup = {
|
||||||
}
|
}
|
||||||
|
|
||||||
test('should match snapshot, no groups', async () => {
|
test('should match snapshot, no groups', async () => {
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<TableGroupHeaderRowElement
|
<TableGroupHeaderRowElement
|
||||||
board={board}
|
board={board}
|
||||||
activeView={view}
|
activeView={view}
|
||||||
|
@ -75,7 +65,7 @@ test('should match snapshot, no groups', async () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should match snapshot with Group', async () => {
|
test('should match snapshot with Group', async () => {
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<TableGroupHeaderRowElement
|
<TableGroupHeaderRowElement
|
||||||
board={board}
|
board={board}
|
||||||
activeView={view}
|
activeView={view}
|
||||||
|
@ -92,7 +82,7 @@ test('should match snapshot with Group', async () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should match snapshot on read only', async () => {
|
test('should match snapshot on read only', async () => {
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<TableGroupHeaderRowElement
|
<TableGroupHeaderRowElement
|
||||||
board={board}
|
board={board}
|
||||||
activeView={view}
|
activeView={view}
|
||||||
|
@ -114,7 +104,7 @@ test('should match snapshot, hide group', async () => {
|
||||||
const collapsedOptionsView = TestBlockFactory.createBoardView(board)
|
const collapsedOptionsView = TestBlockFactory.createBoardView(board)
|
||||||
collapsedOptionsView.fields.collapsedOptionIds = [boardTreeGroup.option.id]
|
collapsedOptionsView.fields.collapsedOptionIds = [boardTreeGroup.option.id]
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<TableGroupHeaderRowElement
|
<TableGroupHeaderRowElement
|
||||||
board={board}
|
board={board}
|
||||||
activeView={collapsedOptionsView}
|
activeView={collapsedOptionsView}
|
||||||
|
@ -141,7 +131,7 @@ test('should match snapshot, hide group', async () => {
|
||||||
test('should match snapshot, add new', async () => {
|
test('should match snapshot, add new', async () => {
|
||||||
const addNew = jest.fn()
|
const addNew = jest.fn()
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<TableGroupHeaderRowElement
|
<TableGroupHeaderRowElement
|
||||||
board={board}
|
board={board}
|
||||||
activeView={view}
|
activeView={view}
|
||||||
|
@ -167,7 +157,7 @@ test('should match snapshot, add new', async () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should match snapshot, edit title', async () => {
|
test('should match snapshot, edit title', async () => {
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<TableGroupHeaderRowElement
|
<TableGroupHeaderRowElement
|
||||||
board={board}
|
board={board}
|
||||||
activeView={view}
|
activeView={view}
|
||||||
|
|
|
@ -4,24 +4,14 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
import {DndProvider} from 'react-dnd'
|
import {wrapDNDIntl} from '../../testUtils'
|
||||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
|
||||||
|
|
||||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
|
|
||||||
import TableHeader from './tableHeader'
|
import TableHeader from './tableHeader'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/table/TableHeaderMenu', () => {
|
describe('components/table/TableHeaderMenu', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const view = TestBlockFactory.createBoardView(board)
|
const view = TestBlockFactory.createBoardView(board)
|
||||||
|
@ -31,7 +21,7 @@ describe('components/table/TableHeaderMenu', () => {
|
||||||
|
|
||||||
test('should match snapshot, title column', async () => {
|
test('should match snapshot, title column', async () => {
|
||||||
const onAutoSizeColumn = jest.fn()
|
const onAutoSizeColumn = jest.fn()
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<TableHeader
|
<TableHeader
|
||||||
readonly={false}
|
readonly={false}
|
||||||
sorted={'none'}
|
sorted={'none'}
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
import {fireEvent, render} from '@testing-library/react'
|
||||||
|
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
|
|
||||||
|
@ -33,8 +34,6 @@ beforeEach(() => {
|
||||||
FetchMock.fn.mockReset()
|
FetchMock.fn.mockReset()
|
||||||
})
|
})
|
||||||
|
|
||||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
|
|
||||||
describe('components/table/TableHeaderMenu', () => {
|
describe('components/table/TableHeaderMenu', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const view = TestBlockFactory.createBoardView(board)
|
const view = TestBlockFactory.createBoardView(board)
|
||||||
|
|
|
@ -5,26 +5,16 @@ import React from 'react'
|
||||||
import {Provider as ReduxProvider} from 'react-redux'
|
import {Provider as ReduxProvider} from 'react-redux'
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
|
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
import {wrapDNDIntl} from '../../testUtils'
|
||||||
|
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
|
|
||||||
import {DndProvider} from 'react-dnd'
|
|
||||||
import {HTML5Backend} from 'react-dnd-html5-backend'
|
|
||||||
|
|
||||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
|
|
||||||
import TableRow from './tableRow'
|
import TableRow from './tableRow'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/table/TableRow', () => {
|
describe('components/table/TableRow', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const view = TestBlockFactory.createBoardView(board)
|
const view = TestBlockFactory.createBoardView(board)
|
||||||
|
@ -55,7 +45,7 @@ describe('components/table/TableRow', () => {
|
||||||
|
|
||||||
test('should match snapshot', async () => {
|
test('should match snapshot', async () => {
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<TableRow
|
<TableRow
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -80,7 +70,7 @@ describe('components/table/TableRow', () => {
|
||||||
|
|
||||||
test('should match snapshot, read-only', async () => {
|
test('should match snapshot, read-only', async () => {
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<TableRow
|
<TableRow
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -105,7 +95,7 @@ describe('components/table/TableRow', () => {
|
||||||
|
|
||||||
test('should match snapshot, isSelected', async () => {
|
test('should match snapshot, isSelected', async () => {
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<TableRow
|
<TableRow
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -133,7 +123,7 @@ describe('components/table/TableRow', () => {
|
||||||
view.fields.hiddenOptionIds = []
|
view.fields.hiddenOptionIds = []
|
||||||
|
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<TableRow
|
<TableRow
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -160,7 +150,7 @@ describe('components/table/TableRow', () => {
|
||||||
view.fields.visiblePropertyIds = ['property1', 'property2']
|
view.fields.visiblePropertyIds = ['property1', 'property2']
|
||||||
|
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<TableRow
|
<TableRow
|
||||||
board={board}
|
board={board}
|
||||||
|
@ -186,7 +176,7 @@ describe('components/table/TableRow', () => {
|
||||||
view.fields.visiblePropertyIds = ['property1', 'property2']
|
view.fields.visiblePropertyIds = ['property1', 'property2']
|
||||||
|
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<TableRow
|
<TableRow
|
||||||
board={board}
|
board={board}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {Provider as ReduxProvider} from 'react-redux'
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
import {fireEvent, render} from '@testing-library/react'
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
|
|
||||||
|
@ -19,6 +18,7 @@ import userEvent from '@testing-library/user-event'
|
||||||
|
|
||||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
import {FetchMock} from '../../test/fetchMock'
|
import {FetchMock} from '../../test/fetchMock'
|
||||||
|
import {wrapDNDIntl} from '../../testUtils'
|
||||||
|
|
||||||
import TableRows from './tableRows'
|
import TableRows from './tableRows'
|
||||||
|
|
||||||
|
@ -28,14 +28,6 @@ beforeEach(() => {
|
||||||
FetchMock.fn.mockReset()
|
FetchMock.fn.mockReset()
|
||||||
})
|
})
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<DndProvider backend={HTML5Backend}>
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
</DndProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/table/TableRows', () => {
|
describe('components/table/TableRows', () => {
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const view = TestBlockFactory.createBoardView(board)
|
const view = TestBlockFactory.createBoardView(board)
|
||||||
|
@ -71,7 +63,7 @@ describe('components/table/TableRows', () => {
|
||||||
const addCard = jest.fn()
|
const addCard = jest.fn()
|
||||||
|
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
const component = wrapProviders(
|
const component = wrapDNDIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<TableRows
|
<TableRows
|
||||||
board={board}
|
board={board}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {ReactElement} from 'react'
|
import React from 'react'
|
||||||
import {render, screen} from '@testing-library/react'
|
import {render, screen} from '@testing-library/react'
|
||||||
import {Provider as ReduxProvider} from 'react-redux'
|
import {Provider as ReduxProvider} from 'react-redux'
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
|
@ -9,15 +9,12 @@ import configureStore from 'redux-mock-store'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import {TestBlockFactory} from '../../test/testBlockFactory'
|
import {TestBlockFactory} from '../../test/testBlockFactory'
|
||||||
|
|
||||||
import ViewHeaderActionsMenu from './viewHeaderActionsMenu'
|
import ViewHeaderActionsMenu from './viewHeaderActionsMenu'
|
||||||
|
|
||||||
const wrapIntl = (children: ReactElement) => (
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
)
|
|
||||||
const board = TestBlockFactory.createBoard()
|
const board = TestBlockFactory.createBoard()
|
||||||
const activeView = TestBlockFactory.createBoardView(board)
|
const activeView = TestBlockFactory.createBoardView(board)
|
||||||
const card = TestBlockFactory.createCard(board)
|
const card = TestBlockFactory.createCard(board)
|
||||||
|
|
|
@ -1,24 +1,15 @@
|
||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
import {Provider as ReduxProvider} from 'react-redux'
|
import {Provider as ReduxProvider} from 'react-redux'
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
|
||||||
import {UserWorkspace} from '../../user'
|
import {UserWorkspace} from '../../user'
|
||||||
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import WorkspaceOptions from './workspaceOptions'
|
import WorkspaceOptions from './workspaceOptions'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/workspaceSwitcher/WorkspaceOptions', () => {
|
describe('components/workspaceSwitcher/WorkspaceOptions', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
|
|
||||||
|
@ -47,7 +38,7 @@ describe('components/workspaceSwitcher/WorkspaceOptions', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<WorkspaceOptions
|
<WorkspaceOptions
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
|
@ -68,7 +59,7 @@ describe('components/workspaceSwitcher/WorkspaceOptions', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<WorkspaceOptions
|
<WorkspaceOptions
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
|
|
|
@ -7,18 +7,12 @@ import {Provider as ReduxProvider} from 'react-redux'
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import {UserWorkspace} from '../../user'
|
import {UserWorkspace} from '../../user'
|
||||||
|
|
||||||
import WorkspaceOptions from './workspaceOptions'
|
import WorkspaceOptions from './workspaceOptions'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('components/workspaceSwitcher/WorkspaceSwitcher', () => {
|
describe('components/workspaceSwitcher/WorkspaceSwitcher', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
|
|
||||||
|
@ -47,7 +41,7 @@ describe('components/workspaceSwitcher/WorkspaceSwitcher', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<WorkspaceOptions
|
<WorkspaceOptions
|
||||||
onChange={() => {}}
|
onChange={() => {}}
|
||||||
|
@ -67,7 +61,7 @@ describe('components/workspaceSwitcher/WorkspaceSwitcher', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<WorkspaceOptions
|
<WorkspaceOptions
|
||||||
onChange={() => {}}
|
onChange={() => {}}
|
||||||
|
|
|
@ -4,8 +4,6 @@ import React from 'react'
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
import {Provider as ReduxProvider} from 'react-redux'
|
import {Provider as ReduxProvider} from 'react-redux'
|
||||||
|
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import {createMemoryHistory} from 'history'
|
import {createMemoryHistory} from 'history'
|
||||||
|
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
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 {Router} from 'react-router-dom'
|
||||||
|
|
||||||
|
import {wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import {UserWorkspace} from '../../user'
|
import {UserWorkspace} from '../../user'
|
||||||
|
|
||||||
import DashboardCenterContent from './centerContent'
|
import DashboardCenterContent from './centerContent'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('pages/dashboard/CenterContent', () => {
|
describe('pages/dashboard/CenterContent', () => {
|
||||||
const mockStore = configureStore([])
|
const mockStore = configureStore([])
|
||||||
const workspace1: UserWorkspace = {
|
const workspace1: UserWorkspace = {
|
||||||
|
@ -51,7 +45,7 @@ describe('pages/dashboard/CenterContent', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<DashboardCenterContent/>
|
<DashboardCenterContent/>
|
||||||
</ReduxProvider>,
|
</ReduxProvider>,
|
||||||
|
@ -67,7 +61,7 @@ describe('pages/dashboard/CenterContent', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<DashboardCenterContent/>
|
<DashboardCenterContent/>
|
||||||
</ReduxProvider>,
|
</ReduxProvider>,
|
||||||
|
@ -86,7 +80,7 @@ describe('pages/dashboard/CenterContent', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<DashboardCenterContent/>
|
<DashboardCenterContent/>
|
||||||
</ReduxProvider>,
|
</ReduxProvider>,
|
||||||
|
@ -107,7 +101,7 @@ describe('pages/dashboard/CenterContent', () => {
|
||||||
|
|
||||||
const history = createMemoryHistory()
|
const history = createMemoryHistory()
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<DashboardCenterContent/>
|
<DashboardCenterContent/>
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
|
||||||
import {render} from '@testing-library/react'
|
import {render} from '@testing-library/react'
|
||||||
|
|
||||||
import configureStore from 'redux-mock-store'
|
import configureStore from 'redux-mock-store'
|
||||||
|
@ -17,16 +15,10 @@ import {UserWorkspace} from '../../user'
|
||||||
|
|
||||||
import {FetchMock} from '../../test/fetchMock'
|
import {FetchMock} from '../../test/fetchMock'
|
||||||
|
|
||||||
import {mockMatchMedia} from '../../testUtils'
|
import {mockMatchMedia, wrapIntl} from '../../testUtils'
|
||||||
|
|
||||||
import DashboardPage from './dashboardPage'
|
import DashboardPage from './dashboardPage'
|
||||||
|
|
||||||
const wrapProviders = (children: any) => {
|
|
||||||
return (
|
|
||||||
<IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
FetchMock.fn.mockReset()
|
FetchMock.fn.mockReset()
|
||||||
})
|
})
|
||||||
|
@ -73,7 +65,7 @@ describe('pages/dashboard/DashboardPage', () => {
|
||||||
|
|
||||||
const history = createMemoryHistory()
|
const history = createMemoryHistory()
|
||||||
|
|
||||||
const component = wrapProviders(
|
const component = wrapIntl(
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
<DashboardPage/>
|
<DashboardPage/>
|
||||||
|
|
|
@ -2,10 +2,19 @@
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
import {IntlProvider} from 'react-intl'
|
import {IntlProvider} from 'react-intl'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import {DndProvider} from 'react-dnd'
|
||||||
|
import {HTML5Backend} from 'react-dnd-html5-backend'
|
||||||
import configureStore, {MockStoreEnhanced} from 'redux-mock-store'
|
import configureStore, {MockStoreEnhanced} from 'redux-mock-store'
|
||||||
import {Middleware} from 'redux'
|
import {Middleware} from 'redux'
|
||||||
|
|
||||||
export const wrapIntl = (children?: React.ReactNode): JSX.Element => <IntlProvider locale='en'>{children}</IntlProvider>
|
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 {
|
export function mockDOM(): void {
|
||||||
window.focus = jest.fn()
|
window.focus = jest.fn()
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {fireEvent, render} from '@testing-library/react'
|
import {fireEvent, render} from '@testing-library/react'
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
import {IntlProvider} from 'react-intl'
|
|
||||||
|
import {wrapIntl} from '../testUtils'
|
||||||
|
|
||||||
import PropertyMenu from './propertyMenu'
|
import PropertyMenu from './propertyMenu'
|
||||||
|
|
||||||
const wrapIntl = (children: any) => <IntlProvider locale='en'>{children}</IntlProvider>
|
|
||||||
|
|
||||||
describe('widgets/PropertyMenu', () => {
|
describe('widgets/PropertyMenu', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Quick fix to disregard console error when unmounting a component
|
// Quick fix to disregard console error when unmounting a component
|
||||||
|
|
Loading…
Reference in a new issue