Spaces:
Sleeping
Sleeping
File size: 1,755 Bytes
13555f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react'
import {render, screen} from '@testing-library/react'
import {Provider as ReduxProvider} from 'react-redux'
import '@testing-library/jest-dom'
import userEvent from '@testing-library/user-event'
import {mockStateStore, wrapIntl} from '../../testUtils'
import ViewHeaderSearch from './viewHeaderSearch'
jest.mock('react-router-dom', () => {
const originalModule = jest.requireActual('react-router-dom')
return {
...originalModule,
useRouteMatch: jest.fn(() => {
return {url: '/board/view'}
}),
}
})
describe('components/viewHeader/ViewHeaderSearch', () => {
const state = {
users: {
me: {
id: 'user-id-1',
username: 'username_1'},
},
searchText: {
},
}
const store = mockStateStore([], state)
beforeEach(() => {
jest.clearAllMocks()
})
test('return search menu', () => {
const {container} = render(
wrapIntl(
<ReduxProvider store={store}>
<ViewHeaderSearch/>
</ReduxProvider>,
),
)
expect(container).toMatchSnapshot()
})
test('search text after input', () => {
const {container} = render(
wrapIntl(
<ReduxProvider store={store}>
<ViewHeaderSearch/>
</ReduxProvider>,
),
)
const elementSearchText = screen.getByPlaceholderText('Search cards')
userEvent.type(elementSearchText, 'Hello')
expect(container).toMatchSnapshot()
})
})
|