overleaf/services/web/test/frontend/features/file-tree/components/file-tree-item/file-tree-item-menu.test.js
Shane Kilkelly f1f8c4e152 Merge pull request #3965 from overleaf/ae-file-tree-popup
Use custom overlay for file tree dropdown menu

GitOrigin-RevId: 261b21953f9331427d6d368716662d7eaec65477
2021-05-01 02:13:14 +00:00

48 lines
1.2 KiB
JavaScript

import React from 'react'
import sinon from 'sinon'
import { expect } from 'chai'
import { screen, fireEvent } from '@testing-library/react'
import renderWithContext from '../../helpers/render-with-context'
import FileTreeitemMenu from '../../../../../../frontend/js/features/file-tree/components/file-tree-item/file-tree-item-menu'
describe('<FileTreeitemMenu />', function () {
const setContextMenuCoords = sinon.stub()
afterEach(function () {
setContextMenuCoords.reset()
})
it('renders dropdown', function () {
renderWithContext(
<FileTreeitemMenu
id="123abc"
setContextMenuCoords={setContextMenuCoords}
/>
)
const toggleButton = screen.getByRole('button', { name: 'Menu' })
fireEvent.click(toggleButton)
screen.getByRole('menu')
})
it('open / close', function () {
renderWithContext(
<FileTreeitemMenu
id="123abc"
setContextMenuCoords={setContextMenuCoords}
/>
)
expect(screen.queryByRole('menu')).to.be.null
const toggleButton = screen.getByRole('button', { name: 'Menu' })
fireEvent.click(toggleButton)
screen.getByRole('menu', { visible: true })
fireEvent.click(toggleButton)
screen.getByRole('menu', { visible: false })
})
})