|
1 | 1 | import { NotionBlock } from "../config/configuration"; |
2 | | -import { blocksToMarkdown } from "../TestRun"; |
| 2 | +import { NotionPage } from "../NotionPage"; |
| 3 | +import { blocksToMarkdown, makeSamplePageObject } from "../TestRun"; |
3 | 4 | import { standardCalloutTransformer } from "./CalloutTransformer"; |
4 | | -import { standardColumnTransformer } from "./ColumnTransformer"; |
| 5 | +import { standardExternalLinkConversion } from "./externalLinks"; |
| 6 | +import { standardInternalLinkConversion } from "./internalLinks"; |
5 | 7 |
|
6 | 8 | let block: any; |
7 | 9 | beforeEach(() => { |
@@ -45,7 +47,13 @@ test("smoketest callout", async () => { |
45 | 47 | }); |
46 | 48 |
|
47 | 49 | test("external link inside callout, bold preserved", async () => { |
48 | | - const config = { plugins: [standardCalloutTransformer] }; |
| 50 | + const config = { |
| 51 | + plugins: [ |
| 52 | + standardCalloutTransformer, |
| 53 | + standardInternalLinkConversion, |
| 54 | + standardExternalLinkConversion, |
| 55 | + ], |
| 56 | + }; |
49 | 57 | const results = await blocksToMarkdown(config, [ |
50 | 58 | { |
51 | 59 | type: "callout", |
@@ -110,3 +118,85 @@ Callouts inline [**great page**](https://github.com). |
110 | 118 | :::` |
111 | 119 | ); |
112 | 120 | }); |
| 121 | + |
| 122 | +test("internal link inside callout, bold preserved", async () => { |
| 123 | + const config = { |
| 124 | + plugins: [ |
| 125 | + standardCalloutTransformer, |
| 126 | + standardInternalLinkConversion, |
| 127 | + standardExternalLinkConversion, |
| 128 | + ], |
| 129 | + }; |
| 130 | + const slugTargetPage: NotionPage = makeSamplePageObject({ |
| 131 | + slug: "hello-world", |
| 132 | + name: "Hello World", |
| 133 | + id: "123", |
| 134 | + }); |
| 135 | + const results = await blocksToMarkdown( |
| 136 | + config, |
| 137 | + [ |
| 138 | + { |
| 139 | + type: "callout", |
| 140 | + callout: { |
| 141 | + rich_text: [ |
| 142 | + { |
| 143 | + type: "text", |
| 144 | + text: { content: "Callouts inline ", link: null }, |
| 145 | + annotations: { |
| 146 | + bold: false, |
| 147 | + italic: false, |
| 148 | + strikethrough: false, |
| 149 | + underline: false, |
| 150 | + code: false, |
| 151 | + color: "default", |
| 152 | + }, |
| 153 | + plain_text: "Callouts inline ", |
| 154 | + href: null, |
| 155 | + }, |
| 156 | + { |
| 157 | + type: "text", |
| 158 | + text: { |
| 159 | + content: "great page", |
| 160 | + link: { url: `/123#456` }, |
| 161 | + }, |
| 162 | + annotations: { |
| 163 | + bold: true, |
| 164 | + italic: false, |
| 165 | + strikethrough: false, |
| 166 | + underline: false, |
| 167 | + code: false, |
| 168 | + color: "default", |
| 169 | + }, |
| 170 | + plain_text: "great page", |
| 171 | + href: `/123#456`, |
| 172 | + }, |
| 173 | + { |
| 174 | + type: "text", |
| 175 | + text: { content: ".", link: null }, |
| 176 | + annotations: { |
| 177 | + bold: false, |
| 178 | + italic: false, |
| 179 | + strikethrough: false, |
| 180 | + underline: false, |
| 181 | + code: false, |
| 182 | + color: "default", |
| 183 | + }, |
| 184 | + plain_text: " the end.", |
| 185 | + href: null, |
| 186 | + }, |
| 187 | + ], |
| 188 | + icon: { type: "emoji", emoji: "⚠️" }, |
| 189 | + color: "gray_background", |
| 190 | + }, |
| 191 | + } as unknown as NotionBlock, |
| 192 | + ], |
| 193 | + [slugTargetPage] |
| 194 | + ); |
| 195 | + expect(results.trim()).toBe( |
| 196 | + `:::caution |
| 197 | +
|
| 198 | +Callouts inline [**great page**](/hello-world#456) the end. |
| 199 | +
|
| 200 | +:::` |
| 201 | + ); |
| 202 | +}); |
0 commit comments