omnivore/packages/api/test/utils/uploads.test.ts

26 lines
854 B
TypeScript
Raw Normal View History

2023-06-05 06:59:27 +00:00
import { expect } from 'chai'
2023-09-06 11:31:34 +00:00
import 'mocha'
2023-09-19 11:33:43 +00:00
import { ContentReader, PageType } from '../../src/generated/graphql'
2023-09-06 11:31:34 +00:00
import { contentReaderForLibraryItem } from '../../src/utils/uploads'
2023-06-05 06:59:27 +00:00
describe('contentReaderForPage', () => {
it('returns web if there is no uploadFileId', () => {
2023-09-19 11:33:43 +00:00
const result = contentReaderForLibraryItem(PageType.Book, undefined)
2023-06-05 06:59:27 +00:00
expect(result).to.eq(ContentReader.Web)
})
it('returns Epub if there is an uploadFileId and type is book', () => {
2023-09-06 11:31:34 +00:00
const result = contentReaderForLibraryItem(
2023-09-19 11:33:43 +00:00
PageType.Book,
2023-09-06 11:31:34 +00:00
'fakeUploadFileId'
)
2023-06-05 06:59:27 +00:00
expect(result).to.eq(ContentReader.Epub)
})
2023-06-05 08:00:50 +00:00
it('returns PDF if there is an uploadFileId and type is File', () => {
2023-09-06 11:31:34 +00:00
const result = contentReaderForLibraryItem(
2023-09-19 11:33:43 +00:00
PageType.File,
2023-09-06 11:31:34 +00:00
'fakeUploadFileId'
)
2023-06-05 06:59:27 +00:00
expect(result).to.eq(ContentReader.Pdf)
})
})