help-menu.test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { screen } from '@testing-library/dom'
  2. import { expect } from 'chai'
  3. import fetchMock from 'fetch-mock'
  4. import HelpMenu from '../../../../../frontend/js/features/editor-left-menu/components/help-menu'
  5. import { renderWithEditorContext } from '../../../helpers/render-with-context'
  6. describe('<HelpMenu />', function () {
  7. beforeEach(function () {
  8. window.metaAttributesCache = new Map()
  9. window.metaAttributesCache.set('ol-user', {
  10. email: 'sherlock@holmes.co.uk',
  11. first_name: 'Sherlock',
  12. last_name: 'Holmes',
  13. })
  14. })
  15. afterEach(function () {
  16. window.metaAttributesCache = new Map()
  17. fetchMock.reset()
  18. })
  19. it('shows correct menu if `showSupport` is `true`', function () {
  20. window.metaAttributesCache.set('ol-showSupport', true)
  21. renderWithEditorContext(<HelpMenu />)
  22. screen.getByRole('button', { name: 'Show Hotkeys' })
  23. screen.getByRole('button', { name: 'Contact Us' })
  24. screen.getByRole('link', { name: 'Documentation' })
  25. })
  26. it('shows correct menu if `showSupport` is `false`', function () {
  27. window.metaAttributesCache.set('ol-showSupport', false)
  28. renderWithEditorContext(<HelpMenu />)
  29. screen.getByRole('button', { name: 'Show Hotkeys' })
  30. expect(screen.queryByRole('button', { name: 'Contact Us' })).to.equal(null)
  31. expect(screen.queryByRole('link', { name: 'Documentation' })).to.equal(null)
  32. })
  33. })