settings-dictionary.test.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { fireEvent, screen, within, render } from '@testing-library/react'
  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 { EditorProviders } from '../../../../helpers/editor-providers'
  6. describe('<SettingsDictionary />', function () {
  7. it('open dictionary modal', function () {
  8. render(
  9. <EditorProviders>
  10. <EditorLeftMenuProvider>
  11. <SettingsDictionary />
  12. </EditorLeftMenuProvider>
  13. </EditorProviders>
  14. )
  15. screen.getByText('Dictionary')
  16. const button = screen.getByText('Edit')
  17. fireEvent.click(button)
  18. const modal = screen.getAllByRole('dialog')[0]
  19. within(modal).getByRole('heading', { name: 'Edit Dictionary' })
  20. within(modal).getByText('Your custom dictionary is empty.')
  21. const [, closeButton] = within(modal).getAllByRole('button', {
  22. name: 'Close',
  23. })
  24. fireEvent.click(closeButton)
  25. expect(screen.queryByRole('dialog')).to.be.null
  26. })
  27. })