Skip to content

Commit 03310fd

Browse files
committed
Improve tests
1 parent d208deb commit 03310fd

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

test/index.test.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createRequire } from "module";
44
import test from "ava";
55
import webpack from "webpack";
66
import { Renderer } from "marked";
7+
import highlighter from "highlight.js";
78

89
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
910
const require = createRequire(import.meta.url);
@@ -105,3 +106,15 @@ test("with custom renderer", async (t) => {
105106

106107
t.assert(code.includes("CUSTOM RENDERER") === false);
107108
});
109+
110+
test("with custom highlighter", async (t) => {
111+
const code = await createBundle({
112+
fixture: "with-code.md",
113+
output: "with-custom-highlighter.cjs",
114+
options: {
115+
highlight: code => highlighter.highlightAuto(code).value,
116+
}
117+
});
118+
119+
t.snapshot(code);
120+
});

test/snapshots/index.test.mjs.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,18 @@ Generated by [AVA](https://avajs.dev).
6060
</ul>␊
6161
<h2 id="heading-2">heading 2</h2>␊
6262
<p><em>italic</em> is the new <strong>bold</strong></p>␊
63+
<pre><code class="language-javascript">const i <span class="hljs-operator">=</span> <span class="hljs-number">100</span><span class="hljs-comment">;</span>␊
64+
</code></pre>␊
6365
<table>␊
6466
<thead>␊
6567
<tr>␊
6668
<th>name</th>␊
6769
<th>type</th>␊
6870
</tr>␊
6971
</thead>␊
70-
</table>␊
72+
<tbody><tr>␊
73+
<td>key</td>␊
74+
<td><code>string|number</code></td>␊
75+
</tr>␊
76+
</tbody></table>␊
7177
`

test/snapshots/index.test.mjs.snap

54 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)