settings-spell-check-language.test.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { screen, within } from '@testing-library/dom'
  2. import { expect } from 'chai'
  3. import fetchMock from 'fetch-mock'
  4. import SettingsSpellCheckLanguage from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language'
  5. import type { SpellCheckLanguage } from '../../../../../../types/project-settings'
  6. import { renderWithEditorContext } from '../../../../helpers/render-with-context'
  7. describe('<SettingsSpellCheckLanguage />', function () {
  8. const languages: SpellCheckLanguage[] = [
  9. {
  10. name: 'Lang 1',
  11. code: 'lang-1',
  12. },
  13. {
  14. name: 'Lang 2',
  15. code: 'lang-2',
  16. },
  17. ]
  18. beforeEach(function () {
  19. window.metaAttributesCache.set('ol-languages', languages)
  20. })
  21. afterEach(function () {
  22. fetchMock.reset()
  23. })
  24. it('shows correct menu', async function () {
  25. renderWithEditorContext(<SettingsSpellCheckLanguage />)
  26. const select = screen.getByLabelText('Spell check')
  27. const optionEmpty = within(select).getByText('Off')
  28. expect(optionEmpty.getAttribute('value')).to.equal('')
  29. for (const language of languages) {
  30. const option = within(select).getByText(language.name)
  31. expect(option.getAttribute('value')).to.equal(language.code)
  32. }
  33. })
  34. })