work.suroh.tk/node_modules/@11ty/eleventy/test/TemplateRenderJSTLTest.js

42 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import test from "ava";
import TemplateRender from "../src/TemplateRender";
// ES6
test("ES6 Template Literal", t => {
t.is(new TemplateRender("jstl").getEngineName(), "jstl");
});
test("ES6 Template Literal Render (Backticks)", async t => {
// pass in a string here, we dont want to compile the template in the test :O
let fn = await new TemplateRender("jstl").getCompiledTemplate(
"`<p>${name.toUpperCase()}</p>`"
);
t.is(await fn({ name: "Tim" }), "<p>TIM</p>");
});
test("ES6 Template Literal Render (No backticks)", async t => {
// pass in a string here, we dont want to compile the template in the test :O
let fn = await new TemplateRender("jstl").getCompiledTemplate(
"<p>${name.toUpperCase()}</p>"
);
t.is(await fn({ name: "Tim" }), "<p>TIM</p>");
});
test("ES6 Template Literal with newlines", async t => {
// pass in a string here, we dont want to compile the template in the test :O
let fn = await new TemplateRender("jstl").getCompiledTemplate(
"Test\n\nMarkdown Syntax ${name}\n"
);
t.is(await fn({ name: "Tim" }), "Test\n\nMarkdown Syntax Tim\n");
});
test("ES6 Template Literal with markdown", async t => {
// pass in a string here, we dont want to compile the template in the test :O
let fn = await new TemplateRender("jstl").getCompiledTemplate(
"Test\n```\nMarkdown Syntax ${name}\n```"
);
// TODO this has an extra newline at the end because the input string ends in a `!
t.is(await fn({ name: "Tim" }), "Test\n```\nMarkdown Syntax Tim\n```\n");
});