overleaf/services/web/test/frontend/features/file-view/components/file-view-text.test.js
Alf Eaton 764234e42b Merge pull request #4158 from overleaf/ae-rename-file-view
Rename `binary-file` components to `file-view`

GitOrigin-RevId: b960d4e6f154ee1a5847782a1fcb1e4e61159603
2021-06-11 02:06:38 +00:00

40 lines
1.1 KiB
JavaScript

import React from 'react'
import { screen } from '@testing-library/react'
import fetchMock from 'fetch-mock'
import { renderWithEditorContext } from '../../../helpers/render-with-context'
import FileViewText from '../../../../../frontend/js/features/file-view/components/file-view-text.js'
describe('<FileViewText/>', function () {
const file = {
name: 'example.tex',
linkedFileData: {
v1_source_doc_id: 'v1-source-id',
source_project_id: 'source-project-id',
source_entity_path: '/source-entity-path.ext',
provider: 'project_file',
},
created: new Date(2021, 1, 17, 3, 24).toISOString(),
}
beforeEach(function () {
fetchMock.reset()
})
it('renders a text view', async function () {
fetchMock.head('express:/project/:project_id/file/:file_id', {
status: 201,
headers: { 'Content-Length': 10000 },
})
fetchMock.get(
'express:/project/:project_id/file/:file_id',
'Text file content'
)
renderWithEditorContext(
<FileViewText file={file} onError={() => {}} onLoad={() => {}} />
)
await screen.findByText('Text file content', { exact: false })
})
})