|
| 1 | +import { NotionToMarkdown } from "notion-to-md"; |
| 2 | +import { HierarchicalNamedLayoutStrategy } from "./HierarchicalNamedLayoutStrategy"; |
| 3 | +import { LayoutStrategy } from "./LayoutStrategy"; |
| 4 | +import { NotionPage } from "./NotionPage"; |
| 5 | + |
| 6 | +import { getMarkdownFromNotionBlocks } from "./transform"; |
| 7 | + |
| 8 | +import { IDocuNotionContext } from "./plugins/pluginTypes"; |
| 9 | +import { convertInternalUrl } from "./plugins/internalLinks"; |
| 10 | + |
| 11 | +import { initNotionClient } from "./pull"; |
| 12 | +import { NotionBlock } from "./types"; |
| 13 | + |
| 14 | +import { IDocuNotionConfig } from "./config/configuration"; |
| 15 | + |
| 16 | +import defaultConfig from "./config/default.docunotion.config"; |
| 17 | + |
| 18 | +test("Latex Rendering", () => { |
| 19 | + let layoutStrategy: LayoutStrategy; |
| 20 | + const pages = new Array<NotionPage>(); |
| 21 | + const counts = { |
| 22 | + output_normally: 0, |
| 23 | + skipped_because_empty: 0, |
| 24 | + skipped_because_status: 0, |
| 25 | + skipped_because_level_cannot_have_content: 0, |
| 26 | + }; |
| 27 | + |
| 28 | + const notionClient = initNotionClient(""); |
| 29 | + |
| 30 | + layoutStrategy = new HierarchicalNamedLayoutStrategy(); |
| 31 | + |
| 32 | + let config: IDocuNotionConfig = defaultConfig; |
| 33 | + |
| 34 | + const context: IDocuNotionContext = { |
| 35 | + getBlockChildren: async function (id: string) { |
| 36 | + return new Array<NotionBlock> |
| 37 | + }, |
| 38 | + directoryContainingMarkdown: "", // this changes with each page |
| 39 | + relativeFilePathToFolderContainingPage: "", // this changes with each page |
| 40 | + layoutStrategy: layoutStrategy, |
| 41 | + notionToMarkdown: new NotionToMarkdown({ notionClient }), |
| 42 | + options: {notionToken: "", rootPage: "", locales: [""], markdownOutputPath: "", imgOutputPath: "", imgPrefixInMarkdown: "", statusTag: ""}, |
| 43 | + |
| 44 | + pages: pages, |
| 45 | + counts: counts, // review will this get copied or pointed to? |
| 46 | + imports: [], |
| 47 | + convertNotionLinkToLocalDocusaurusLink: (url: string) => |
| 48 | + convertInternalUrl(context, url), |
| 49 | + }; |
| 50 | + |
| 51 | + const blocks: Array<NotionBlock> = [{ |
| 52 | + object: 'block', |
| 53 | + id: '169e1c47-6706-4518-adca-73086b2738ac', |
| 54 | + parent: { type: 'page_id', page_id: '2acc11a4-82a9-4759-b429-fa011c164888' }, |
| 55 | + created_time: '2023-08-18T15:51:00.000Z', |
| 56 | + last_edited_time: '2023-08-18T15:51:00.000Z', |
| 57 | + created_by: { object: 'user', id: 'af5c163e-82b1-49d1-9f1c-539907bb9fb9' }, |
| 58 | + last_edited_by: { object: 'user', id: 'af5c163e-82b1-49d1-9f1c-539907bb9fb9' }, |
| 59 | + has_children: false, |
| 60 | + archived: false, |
| 61 | + type: 'paragraph', |
| 62 | + paragraph: { rich_text: [ { |
| 63 | + type: 'equation', |
| 64 | + equation: { expression: 'x' }, |
| 65 | + annotations: { |
| 66 | + bold: false, |
| 67 | + italic: false, |
| 68 | + strikethrough: false, |
| 69 | + underline: false, |
| 70 | + code: false, |
| 71 | + color: 'default' |
| 72 | + }, |
| 73 | + plain_text: 'x', |
| 74 | + href: null |
| 75 | + } ], color: 'default' } |
| 76 | + }]; |
| 77 | + |
| 78 | + expect(getMarkdownFromNotionBlocks(context, config, blocks)).resolves.toContain("$x$"); |
| 79 | + }); |
| 80 | + |
0 commit comments