2022-12-22 16:32:39 +01:00
|
|
|
import React from 'react'
|
|
|
|
import {Menu} from '../../../../src/view/shell/mobile/Menu'
|
2023-01-17 17:06:00 +01:00
|
|
|
import {cleanup, fireEvent, render} from '../../../../jest/test-utils'
|
|
|
|
import {
|
|
|
|
mockedNavigationStore,
|
|
|
|
mockedShellStore,
|
|
|
|
} from '../../../../__mocks__/state-mock'
|
2022-12-22 16:32:39 +01:00
|
|
|
|
|
|
|
describe('Menu', () => {
|
2023-01-17 17:06:00 +01:00
|
|
|
const onCloseMock = jest.fn()
|
|
|
|
|
2022-12-22 16:32:39 +01:00
|
|
|
const mockedProps = {
|
|
|
|
visible: true,
|
2023-01-17 17:06:00 +01:00
|
|
|
onClose: onCloseMock,
|
2022-12-22 16:32:39 +01:00
|
|
|
}
|
2023-01-17 17:06:00 +01:00
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
jest.clearAllMocks()
|
|
|
|
cleanup()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('renders menu', () => {
|
|
|
|
const {getByTestId} = render(<Menu {...mockedProps} />)
|
|
|
|
|
|
|
|
const menuView = getByTestId('menuView')
|
|
|
|
|
|
|
|
expect(menuView).toBeTruthy()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('presses profile card button', () => {
|
|
|
|
const {getByTestId} = render(<Menu {...mockedProps} />)
|
|
|
|
|
|
|
|
const profileCardButton = getByTestId('profileCardButton')
|
|
|
|
fireEvent.press(profileCardButton)
|
|
|
|
|
|
|
|
expect(onCloseMock).toHaveBeenCalled()
|
|
|
|
expect(mockedNavigationStore.switchTo).toHaveBeenCalledWith(0, true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('presses search button', () => {
|
|
|
|
const {getByTestId} = render(<Menu {...mockedProps} />)
|
|
|
|
|
|
|
|
const searchBtn = getByTestId('searchBtn')
|
|
|
|
fireEvent.press(searchBtn)
|
|
|
|
|
|
|
|
expect(onCloseMock).toHaveBeenCalled()
|
|
|
|
expect(mockedNavigationStore.switchTo).toHaveBeenCalledWith(0, true)
|
|
|
|
expect(mockedNavigationStore.navigate).toHaveBeenCalledWith('/search')
|
|
|
|
})
|
|
|
|
|
|
|
|
it("presses notifications menu item' button", () => {
|
|
|
|
const {getAllByTestId} = render(<Menu {...mockedProps} />)
|
|
|
|
|
|
|
|
const menuItemButton = getAllByTestId('menuItemButton')
|
|
|
|
fireEvent.press(menuItemButton[1])
|
|
|
|
|
|
|
|
expect(onCloseMock).toHaveBeenCalled()
|
|
|
|
expect(mockedNavigationStore.switchTo).toHaveBeenCalledWith(1, true)
|
|
|
|
})
|
2022-12-22 16:32:39 +01:00
|
|
|
})
|