help-menu.test.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { screen } from '@testing-library/react'
  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.set('ol-user', {
  9. email: 'sherlock@holmes.co.uk',
  10. first_name: 'Sherlock',
  11. last_name: 'Holmes',
  12. })
  13. })
  14. afterEach(function () {
  15. fetchMock.removeRoutes().clearHistory()
  16. })
  17. it('shows correct menu if `showSupport` is `true`', function () {
  18. window.metaAttributesCache.set('ol-showSupport', true)
  19. renderWithEditorContext(<HelpMenu />)
  20. screen.getByRole('button', { name: 'Show Hotkeys' })
  21. screen.getByRole('button', { name: 'Contact Us' })
  22. screen.getByRole('link', { name: 'Documentation' })
  23. })
  24. it('shows correct menu if `showSupport` is `false`', function () {
  25. window.metaAttributesCache.set('ol-showSupport', false)
  26. renderWithEditorContext(<HelpMenu />)
  27. screen.getByRole('button', { name: 'Show Hotkeys' })
  28. expect(screen.queryByRole('button', { name: 'Contact Us' })).to.equal(null)
  29. expect(screen.queryByRole('link', { name: 'Documentation' })).to.equal(null)
  30. })
  31. })