settings-dictionary.test.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { fireEvent, screen, within } from '@testing-library/dom'
  2. import { expect } from 'chai'
  3. import SettingsDictionary from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-dictionary'
  4. import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
  5. import { render } from '@testing-library/react'
  6. import { EditorProviders } from '../../../../helpers/editor-providers'
  7. describe('<SettingsDictionary />', function () {
  8. it('open dictionary modal', function () {
  9. render(
  10. <EditorProviders>
  11. <EditorLeftMenuProvider>
  12. <SettingsDictionary />
  13. </EditorLeftMenuProvider>
  14. </EditorProviders>
  15. )
  16. screen.getByText('Dictionary')
  17. const button = screen.getByText('Edit')
  18. fireEvent.click(button)
  19. const modal = screen.getAllByRole('dialog')[0]
  20. within(modal).getByRole('heading', { name: 'Edit Dictionary' })
  21. within(modal).getByText('Your custom dictionary is empty.')
  22. const [, closeButton] = within(modal).getAllByRole('button', {
  23. name: 'Close',
  24. })
  25. fireEvent.click(closeButton)
  26. expect(screen.queryByRole('dialog')).to.be.null
  27. })
  28. })