help-contact-us.test.jsx 979 B

1234567891011121314151617181920212223242526272829
  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.set('ol-user', {
  9. email: 'sherlock@holmes.co.uk',
  10. first_name: 'Sherlock',
  11. last_name: 'Holmes',
  12. })
  13. })
  14. afterEach(function () {
  15. fetchMock.reset()
  16. })
  17. it('open contact us modal when clicked', function () {
  18. renderWithEditorContext(<HelpContactUs />)
  19. expect(screen.queryByRole('dialog')).to.equal(null)
  20. fireEvent.click(screen.getByRole('button', { name: 'Contact Us' }))
  21. const modal = screen.getAllByRole('dialog')[0]
  22. within(modal).getAllByText('Get in touch')
  23. within(modal).getByText('Subject')
  24. })
  25. })