Skip to content

Commit

Permalink
Two more tests for #2438
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jun 16, 2022
1 parent 1bdbd24 commit e65e9d2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/TemplateRenderMarkdownTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,22 @@ test("Markdown Render: use amendLibrary to re-enable indented code blocks. Issue

let tr = getNewTemplateRender("md", null, eleventyConfig);

let fn = await tr.getCompiledTemplate(" This is a test");
let content = await fn();
t.is(
normalizeNewLines(content.trim()),
`<pre><code>This is a test
</code></pre>`
);
});

test("Markdown Render: amendLibrary works with setLibrary to re-enable indented code blocks. Issue #2438", async (t) => {
let eleventyConfig = new TemplateConfig();
let userConfig = eleventyConfig.userConfig;
userConfig.amendLibrary("md", (lib) => lib.enable("code"));

let tr = getNewTemplateRender("md", null, eleventyConfig);

let mdLib = md();
tr.engine.setLibrary(mdLib);

Expand All @@ -391,6 +407,27 @@ test("Markdown Render: use amendLibrary to re-enable indented code blocks. Issue
);
});

test("Markdown Render: multiple amendLibrary calls. Issue #2438", async (t) => {
t.plan(3);

let eleventyConfig = new TemplateConfig();
let userConfig = eleventyConfig.userConfig;
userConfig.amendLibrary("md", (lib) => {
t.true(true);
lib.enable("code");
});
userConfig.amendLibrary("md", (lib) => {
t.true(true);
lib.disable("code");
});

let tr = getNewTemplateRender("md", null, eleventyConfig);

let fn = await tr.getCompiledTemplate(" This is a test");
let content = await fn();
t.is(normalizeNewLines(content.trim()), "<p>This is a test</p>");
});

test("Markdown Render: use amendLibrary to add a Plugin", async (t) => {
let eleventyConfig = new TemplateConfig();
let userConfig = eleventyConfig.userConfig;
Expand Down

1 comment on commit e65e9d2

@Nahaat
Copy link

@Nahaat Nahaat commented on e65e9d2 Jun 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/TemplateRenderMarkdownTest.js

Please sign in to comment.