2021-11-03 09:21:14 -04:00
|
|
|
import { render, screen } from '@testing-library/react'
|
|
|
|
import LayoutDropdownButton from '../../../../../frontend/js/features/editor-navigation-toolbar/components/layout-dropdown-button'
|
|
|
|
|
|
|
|
describe('<LayoutDropdownButton />', function () {
|
|
|
|
const defaultProps = {
|
2021-11-15 11:33:57 -05:00
|
|
|
reattach: () => {},
|
|
|
|
detach: () => {},
|
2021-11-03 09:21:14 -04:00
|
|
|
handleChangeLayout: () => {},
|
2021-11-15 11:33:57 -05:00
|
|
|
detachMode: undefined,
|
|
|
|
detachRole: undefined,
|
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-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-03 09:21:14 -04:00
|
|
|
render(<LayoutDropdownButton {...defaultProps} />)
|
|
|
|
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', {
|
|
|
|
name: 'Open PDF in new tab',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should select Editor Only when detached and show option to reattach', function () {
|
|
|
|
const detachedProps = Object.assign({}, defaultProps, {
|
|
|
|
detachMode: 'detacher',
|
|
|
|
detachRole: 'detacher',
|
|
|
|
view: 'editor',
|
|
|
|
})
|
|
|
|
|
|
|
|
render(<LayoutDropdownButton {...detachedProps} />)
|
|
|
|
|
2021-11-03 09:21:14 -04:00
|
|
|
screen.getByRole('menuitem', {
|
|
|
|
name: 'Selected Editor only (hide PDF)',
|
|
|
|
})
|
2021-11-15 11:33:57 -05:00
|
|
|
screen.getByRole('menuitem', {
|
|
|
|
name: 'Bring PDF back to this tab',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should show processing when detaching', function () {
|
|
|
|
const detachedProps = Object.assign({}, defaultProps, {
|
|
|
|
detachMode: 'detaching',
|
|
|
|
detachRole: 'detacher',
|
|
|
|
view: 'editor',
|
|
|
|
})
|
|
|
|
|
|
|
|
render(<LayoutDropdownButton {...detachedProps} />)
|
|
|
|
|
|
|
|
screen.getByText('Layout processing')
|
2021-11-03 09:21:14 -04:00
|
|
|
})
|
|
|
|
})
|