settings-image-name.test.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { screen, within } from '@testing-library/dom'
  2. import { expect } from 'chai'
  3. import fetchMock from 'fetch-mock'
  4. import SettingsImageName from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-image-name'
  5. import type { AllowedImageName } from '../../../../../../types/project-settings'
  6. import { renderWithEditorContext } from '../../../../helpers/render-with-context'
  7. describe('<SettingsImageName />', function () {
  8. const allowedImageNames: AllowedImageName[] = [
  9. {
  10. imageDesc: 'Image 1',
  11. imageName: 'img-1',
  12. },
  13. {
  14. imageDesc: 'Image 2',
  15. imageName: 'img-2',
  16. },
  17. ]
  18. beforeEach(function () {
  19. window.metaAttributesCache.set('ol-allowedImageNames', allowedImageNames)
  20. })
  21. afterEach(function () {
  22. fetchMock.reset()
  23. window.metaAttributesCache = new Map()
  24. })
  25. it('shows correct menu', async function () {
  26. renderWithEditorContext(<SettingsImageName />)
  27. const select = screen.getByLabelText('TeX Live version')
  28. for (const { imageName, imageDesc } of allowedImageNames) {
  29. const option = within(select).getByText(imageDesc)
  30. expect(option.getAttribute('value')).to.equal(imageName)
  31. }
  32. })
  33. })