Skip to content

Commit

Permalink
Tests for #760
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 15, 2019
1 parent 505dea5 commit ccbaf5a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/PaginationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,3 +781,16 @@ test("Pagination new v0.10.0 alias", async t => {
t.is(templates[0].data.pagination.alias, "font.test");
t.is(templates[1].data.pagination.alias, "font.test");
});

test("Pagination make sure pageNumber is numeric for {{ pageNumber + 1 }} Issue #760", async t => {
let tmpl = new Template(
"./test/stubs/paged/pagedinlinedata.njk",
"./test/stubs/",
"./dist"
);

let data = await tmpl.getData();
let templates = await tmpl.getTemplates(data);
t.is(templates[0].data.pagination.pageNumber, 0);
t.not(templates[0].data.pagination.pageNumber, "0");
});
8 changes: 8 additions & 0 deletions test/TemplateRenderLiquidTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ test("Liquid", t => {
t.is(new TemplateRender("liquid").getEngineName(), "liquid");
});

test("Liquid Render Addition", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
"<p>{{ number | plus: 1 }}</p>"
);
// Important for pagination. This currently outputs 1.
t.is(await fn({ number: 1 }), "<p>2</p>");
});

test("Liquid Render (with Helper)", async t => {
let fn = await new TemplateRender("liquid").getCompiledTemplate(
"<p>{{name | capitalize}}</p>"
Expand Down
7 changes: 7 additions & 0 deletions test/TemplateRenderNunjucksTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ test("Nunjucks Render", async t => {
t.is(await fn({ name: "Zach" }), "<p>Zach</p>");
});

test("Nunjucks Render Addition", async t => {
let fn = await new TemplateRender("njk").getCompiledTemplate(
"<p>{{ number + 1 }}</p>"
);
t.is(await fn({ number: 1 }), "<p>2</p>");
});

test("Nunjucks Render Extends", async t => {
let fn = await new TemplateRender("njk", "test/stubs").getCompiledTemplate(
"{% extends 'base.njk' %}{% block content %}This is a child.{% endblock %}"
Expand Down

0 comments on commit ccbaf5a

Please sign in to comment.