switch-to-pdf-button.test.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { screen } from '@testing-library/react'
  2. import { expect } from 'chai'
  3. import { renderWithEditorContext } from '../../../helpers/render-with-context'
  4. import SwitchToPDFButton from '../../../../../frontend/js/features/source-editor/components/switch-to-pdf-button'
  5. describe('<SwitchToPDFButton />', function () {
  6. beforeEach(function () {
  7. window.metaAttributesCache = new Map()
  8. })
  9. afterEach(function () {
  10. window.metaAttributesCache = new Map()
  11. })
  12. it('shows button in full screen layout', function () {
  13. renderWithEditorContext(<SwitchToPDFButton />, {
  14. ui: { view: 'editor', pdfLayout: 'flat' },
  15. })
  16. screen.getByRole('button', { name: 'Switch to PDF' })
  17. })
  18. it('does not show button in split screen layout', function () {
  19. renderWithEditorContext(<SwitchToPDFButton />, {
  20. ui: { view: 'editor', pdfLayout: 'sideBySide' },
  21. })
  22. expect(screen.queryByRole('button', { name: 'Full screen' })).to.not.exist
  23. })
  24. it('does not show button when detached', function () {
  25. window.metaAttributesCache.set('ol-detachRole', 'detacher')
  26. renderWithEditorContext(<SwitchToPDFButton />, {
  27. ui: { view: 'editor', pdfLayout: 'flat' },
  28. })
  29. expect(screen.queryByRole('button', { name: 'Full screen' })).to.not.exist
  30. })
  31. })