Skip to content

Commit

Permalink
Merge branch 'master' into zl/serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed May 27, 2021
2 parents dd126ec + 6be2a09 commit 5e7bb68
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/PaginationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,41 @@ test("Pagination make sure pageNumber is numeric for {{ pageNumber + 1 }} Issue
t.is(templates[0].data.pagination.pageNumber, 0);
t.not(templates[0].data.pagination.pageNumber, "0");
});

test("Pagination mutable global data", async (t) => {
let eleventyConfig = new TemplateConfig();
let dataObj = new TemplateData(
"./test/stubs/paged-global-data-mutable/",
eleventyConfig
);
await dataObj.cacheData();

let tmpl = getNewTemplate(
"./test/stubs/paged-global-data-mutable/paged-differing-data-set.njk",
"./test/stubs/",
"./dist",
dataObj,
null,
eleventyConfig
);

let data = await tmpl.getData();
let templates = await tmpl.getTemplates(data);
t.is(templates.length, 3);
t.deepEqual(templates[0].data.pagination.items[0], {
key1: "item1",
key2: "item2",
});
t.deepEqual(templates[1].data.pagination.items[0], {
key3: "item3",
key4: "item4",
});
t.deepEqual(templates[2].data.pagination.items[0], {
key5: "item5",
key6: "item6",
});

t.deepEqual(templates[0].data.item, { key1: "item1", key2: "item2" });
t.deepEqual(templates[1].data.item, { key3: "item3", key4: "item4" });
t.deepEqual(templates[2].data.item, { key5: "item5", key6: "item6" });
});
14 changes: 14 additions & 0 deletions test/stubs/paged-global-data-mutable/_data/testdata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = [
{
key1: "item1",
key2: "item2",
},
{
key3: "item3",
key4: "item4",
},
{
key5: "item5",
key6: "item6",
},
];
12 changes: 12 additions & 0 deletions test/stubs/paged-global-data-mutable/paged-differing-data-set.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
pagination:
data: testdata
size: 1
alias: item
---
1:{{ item.key1 }}
2:{{ item.key2 }}
3:{{ item.key3 }}
4:{{ item.key4 }}
5:{{ item.key5 }}
6:{{ item.key6 }}

0 comments on commit 5e7bb68

Please sign in to comment.