Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Jan 27, 2022
1 parent d208deb commit 03310fd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions test/index.test.mjs
Expand Up @@ -4,6 +4,7 @@ import { createRequire } from "module";
import test from "ava";
import webpack from "webpack";
import { Renderer } from "marked";
import highlighter from "highlight.js";

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

t.assert(code.includes("CUSTOM RENDERER") === false);
});

test("with custom highlighter", async (t) => {
const code = await createBundle({
fixture: "with-code.md",
output: "with-custom-highlighter.cjs",
options: {
highlight: code => highlighter.highlightAuto(code).value,
}
});

t.snapshot(code);
});
8 changes: 7 additions & 1 deletion test/snapshots/index.test.mjs.md
Expand Up @@ -60,12 +60,18 @@ Generated by [AVA](https://avajs.dev).
</ul>␊
<h2 id="heading-2">heading 2</h2>␊
<p><em>italic</em> is the new <strong>bold</strong></p>␊
<pre><code class="language-javascript">const i <span class="hljs-operator">=</span> <span class="hljs-number">100</span><span class="hljs-comment">;</span>␊
</code></pre>␊
<table>␊
<thead>␊
<tr>␊
<th>name</th>␊
<th>type</th>␊
</tr>␊
</thead>␊
</table>␊
<tbody><tr>␊
<td>key</td>␊
<td><code>string|number</code></td>␊
</tr>␊
</tbody></table>␊
`
Binary file modified test/snapshots/index.test.mjs.snap
Binary file not shown.

0 comments on commit 03310fd

Please sign in to comment.