Skip to content

Commit

Permalink
Adds tests for #680.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jul 11, 2020
1 parent d3dfcec commit dc51a11
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/TemplateRenderLiquidTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,3 +976,45 @@ test("Liquid Render a false #1069", async t => {
);
t.is(await fn({ falseValue: false }), "false");
});

test("Liquid Render Square Brackets dash single quotes", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
"<p>{{ test['hey-a'] }}</p>"
);
t.is(await fn({ test: { "hey-a": 1 } }), "<p>1</p>");
});

test.skip("Liquid Render Square Brackets dash single quotes spaces", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
"<p>{{ test[ 'hey-a' ] }}</p>"
);
t.is(await fn({ test: { "hey-a": 1 } }), "<p>1</p>");
});

test("Liquid Render Square Brackets dash double quotes", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
'<p>{{ test["hey-a"] }}</p>'
);
t.is(await fn({ test: { "hey-a": 1 } }), "<p>1</p>");
});

test.skip("Liquid Render Square Brackets dash double quotes spaces", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
'<p>{{ test[ "hey-a" ] }}</p>'
);
t.is(await fn({ test: { "hey-a": 1 } }), "<p>1</p>");
});

test("Liquid Render Square Brackets variable reference", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
"<p>{{ test[ref] }}</p>"
);
t.is(await fn({ test: { "hey-a": 1 }, ref: "hey-a" }), "<p>1</p>");
});

test.skip("Liquid Render Square Brackets variable reference array", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
"<p>{{ test[ref[0]] }}</p>"
);
t.is(await fn({ test: { "hey-a": 1 }, ref: ["hey-a"] }), "<p>1</p>");
});

0 comments on commit dc51a11

Please sign in to comment.