file-view-text.test.tsx 961 B

123456789101112131415161718192021222324252627282930
  1. import { screen } from '@testing-library/react'
  2. import fetchMock from 'fetch-mock'
  3. import { renderWithEditorContext } from '../../../helpers/render-with-context'
  4. import FileViewText from '../../../../../frontend/js/features/file-view/components/file-view-text'
  5. import { textFile } from '../util/files'
  6. describe('<FileViewText/>', function () {
  7. beforeEach(function () {
  8. fetchMock.removeRoutes().clearHistory()
  9. window.metaAttributesCache.set('ol-preventCompileOnLoad', true)
  10. })
  11. it('renders a text view', async function () {
  12. fetchMock.head('express:/project/:project_id/blob/:hash', {
  13. status: 201,
  14. headers: { 'Content-Length': 10000 },
  15. })
  16. fetchMock.get(
  17. 'express:/project/:project_id/blob/:hash',
  18. 'Text file content'
  19. )
  20. renderWithEditorContext(
  21. <FileViewText file={textFile} onError={() => {}} onLoad={() => {}} />
  22. )
  23. await screen.findByText('Text file content', { exact: false })
  24. })
  25. })