help-contact-us.test.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import { expect } from 'chai'
  2. import { screen, fireEvent, within } from '@testing-library/react'
  3. import HelpContactUs from '../../../../../frontend/js/features/editor-left-menu/components/help-contact-us'
  4. import { renderWithEditorContext } from '../../../helpers/render-with-context'
  5. import fetchMock from 'fetch-mock'
  6. describe('<HelpContactUs />', 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('open contact us modal when clicked', function () {
  20. renderWithEditorContext(<HelpContactUs />)
  21. expect(screen.queryByRole('dialog')).to.equal(null)
  22. fireEvent.click(screen.getByRole('button', { name: 'Contact Us' }))
  23. const modal = screen.getAllByRole('dialog')[0]
  24. within(modal).getAllByText('Contact Us')
  25. within(modal).getByText('Subject')
  26. })
  27. })