2021-11-30 09:54:14 -05:00
|
|
|
import sinon from 'sinon'
|
|
|
|
import { fireEvent, screen } from '@testing-library/react'
|
2021-11-03 09:21:14 -04:00
|
|
|
import LayoutDropdownButton from '../../../../../frontend/js/features/editor-navigation-toolbar/components/layout-dropdown-button'
|
2021-11-30 09:54:14 -05:00
|
|
|
import { renderWithEditorContext } from '../../../helpers/render-with-context'
|
2021-11-03 09:21:14 -04:00
|
|
|
|
|
|
|
describe('<LayoutDropdownButton />', function () {
|
2021-11-30 09:54:14 -05:00
|
|
|
let openStub
|
|
|
|
const defaultUi = {
|
2021-11-03 09:21:14 -04:00
|
|
|
pdfLayout: 'flat',
|
2021-11-15 11:33:57 -05:00
|
|
|
view: 'pdf',
|
2021-11-03 09:21:14 -04:00
|
|
|
}
|
|
|
|
|
2021-11-30 09:54:14 -05:00
|
|
|
beforeEach(function () {
|
|
|
|
openStub = sinon.stub(window, 'open')
|
|
|
|
})
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
openStub.restore()
|
|
|
|
})
|
|
|
|
|
2021-11-15 11:33:57 -05:00
|
|
|
it('should mark current layout option as selected', function () {
|
|
|
|
// Selected is aria-label, visually we show a checkmark
|
2021-11-30 09:54:14 -05:00
|
|
|
renderWithEditorContext(<LayoutDropdownButton />, { ui: defaultUi })
|
2021-11-03 09:21:14 -04:00
|
|
|
screen.getByRole('menuitem', {
|
|
|
|
name: 'Editor & PDF',
|
|
|
|
})
|
|
|
|
screen.getByRole('menuitem', {
|
2021-11-15 11:33:57 -05:00
|
|
|
name: 'Selected PDF only (hide editor)',
|
2021-11-03 09:21:14 -04:00
|
|
|
})
|
2021-11-15 11:33:57 -05:00
|
|
|
screen.getByRole('menuitem', {
|
|
|
|
name: 'Editor only (hide PDF)',
|
|
|
|
})
|
|
|
|
screen.getByRole('menuitem', {
|
2021-11-30 09:54:14 -05:00
|
|
|
name: 'PDF in separate tab',
|
2021-11-15 11:33:57 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should show processing when detaching', function () {
|
2021-11-30 09:54:14 -05:00
|
|
|
renderWithEditorContext(<LayoutDropdownButton />, {
|
|
|
|
ui: { ...defaultUi, view: 'editor' },
|
2021-11-15 11:33:57 -05:00
|
|
|
})
|
|
|
|
|
2021-11-30 09:54:14 -05:00
|
|
|
const menuItem = screen.getByRole('menuitem', {
|
|
|
|
name: 'PDF in separate tab',
|
|
|
|
})
|
|
|
|
fireEvent.click(menuItem)
|
2021-11-15 11:33:57 -05:00
|
|
|
|
|
|
|
screen.getByText('Layout processing')
|
2021-11-03 09:21:14 -04:00
|
|
|
})
|
|
|
|
})
|