Skip to content

Commit

Permalink
Test for #75
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Apr 12, 2023
1 parent 1016319 commit 2cd9429
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
13 changes: 13 additions & 0 deletions test/EleventyTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const test = require("ava");
const Eleventy = require('@11ty/eleventy');

test("Diff output escaped #75", async t => {
let elev = new Eleventy("./test/issue-75/", "./test/issue-75/_site/", {
configPath: "./test/issue-75/.eleventy.js"
});
let json = await elev.toJSON();

t.is(json.length, 1);
t.is(json[0].content.trim(), `<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Hello<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span></code></pre>
<pre class="language-diff-html"><code class="language-diff-html"><span class="token deleted-sign deleted language-html"><span class="token prefix deleted">-</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Hello<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span></span></code></pre>`);
});
2 changes: 1 addition & 1 deletion test/JavaScriptFunctionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test("JavaScript Function", async t => {
t.is(`<pre class="language-js"><code class="language-js"><span class="token keyword">var</span> test<span class="token punctuation">;</span></code></pre>`, rendered);
});

test("JavaScript Function Diff", async t => {
test("JavaScript Function Diff #76", async t => {
let elev = new Eleventy("./test/11tyjs-diff/", "./test/11tyjs-diff/_site/", {
configPath: "./test/11tyjs-diff/.eleventy.js"
});
Expand Down
5 changes: 5 additions & 0 deletions test/issue-75/.eleventy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const syntaxHighlight = require("../../");

module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight);
};
6 changes: 6 additions & 0 deletions test/issue-75/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% highlight "html" %}
<p>Hello</p>
{% endhighlight %}
{% highlight "diff-html" %}
-<p>Hello</p>
{% endhighlight %}

0 comments on commit 2cd9429

Please sign in to comment.