detach-compile-button.test.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import DetachCompileButton from '../../../../../frontend/js/features/pdf-preview/components/detach-compile-button'
  2. import { renderWithEditorContext } from '../../../helpers/render-with-context'
  3. import { screen } from '@testing-library/react'
  4. import sysendTestHelper from '../../../helpers/sysend'
  5. import { expect } from 'chai'
  6. describe('<DetachCompileButton/>', function () {
  7. afterEach(function () {
  8. window.metaAttributesCache = new Map()
  9. sysendTestHelper.resetHistory()
  10. })
  11. it('detacher mode and linked: show button ', async function () {
  12. window.metaAttributesCache.set('ol-detachRole', 'detacher')
  13. renderWithEditorContext(<DetachCompileButton />)
  14. sysendTestHelper.receiveMessage({
  15. role: 'detached',
  16. event: 'connected',
  17. })
  18. await screen.getByRole('button', {
  19. name: 'Recompile',
  20. })
  21. })
  22. it('detacher mode and not linked: does not show button ', async function () {
  23. window.metaAttributesCache.set('ol-detachRole', 'detacher')
  24. renderWithEditorContext(<DetachCompileButton />)
  25. expect(
  26. await screen.queryByRole('button', {
  27. name: 'Recompile',
  28. })
  29. ).to.not.exist
  30. })
  31. it('not detacher mode and linked: does not show button ', async function () {
  32. window.metaAttributesCache.set('ol-detachRole', 'detached')
  33. renderWithEditorContext(<DetachCompileButton />)
  34. sysendTestHelper.receiveMessage({
  35. role: 'detacher',
  36. event: 'connected',
  37. })
  38. expect(
  39. await screen.queryByRole('button', {
  40. name: 'Recompile',
  41. })
  42. ).to.not.exist
  43. })
  44. })