From 51186a195f1b3e7bf98b01131bea6e060a76dbcc Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 5 Jun 2023 14:59:27 +0800 Subject: [PATCH] Add test for content type func --- packages/api/test/utils/uploads.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/api/test/utils/uploads.test.ts diff --git a/packages/api/test/utils/uploads.test.ts b/packages/api/test/utils/uploads.test.ts new file mode 100644 index 000000000..d3f601d20 --- /dev/null +++ b/packages/api/test/utils/uploads.test.ts @@ -0,0 +1,20 @@ +import 'mocha' +import { expect } from 'chai' +import 'chai/register-should' +import { contentReaderForPage } from '../../src/utils/uploads' +import { ContentReader, PageType } from '../../src/generated/graphql' + +describe('contentReaderForPage', () => { + it('returns web if there is no uploadFileId', () => { + const result = contentReaderForPage(PageType.Book, undefined) + expect(result).to.eq(ContentReader.Web) + }) + it('returns Epub if there is an uploadFileId and type is book', () => { + const result = contentReaderForPage(PageType.Book, 'fakeUploadFileId') + expect(result).to.eq(ContentReader.Epub) + }) + it('returns PDF if there is an uploadFileId and type is not File', () => { + const result = contentReaderForPage(PageType.File, 'fakeUploadFileId') + expect(result).to.eq(ContentReader.Pdf) + }) +})