settings-overall-theme.test.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { screen, within } from '@testing-library/dom'
  2. import { expect } from 'chai'
  3. import fetchMock from 'fetch-mock'
  4. import SettingsOverallTheme from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-overall-theme'
  5. import type { OverallThemeMeta } from '../../../../../../types/project-settings'
  6. import { renderWithEditorContext } from '../../../../helpers/render-with-context'
  7. describe('<SettingsOverallTheme />', function () {
  8. const overallThemes: OverallThemeMeta[] = [
  9. {
  10. name: 'Overall Theme 1',
  11. val: '',
  12. path: 'https://overleaf.com/overalltheme-1.css',
  13. },
  14. {
  15. name: 'Overall Theme 2',
  16. val: 'light-',
  17. path: 'https://overleaf.com/overalltheme-2.css',
  18. },
  19. ]
  20. beforeEach(function () {
  21. window.metaAttributesCache.set('ol-overallThemes', overallThemes)
  22. })
  23. afterEach(function () {
  24. fetchMock.reset()
  25. window.metaAttributesCache = new Map()
  26. })
  27. it('shows correct menu', async function () {
  28. renderWithEditorContext(<SettingsOverallTheme />)
  29. const select = screen.getByLabelText('Overall theme')
  30. for (const theme of overallThemes) {
  31. const option = within(select).getByText(theme.name)
  32. expect(option.getAttribute('value')).to.equal(theme.val)
  33. }
  34. })
  35. })