Skip to content

Commit

Permalink
Test for #289 (skipped because it’s failing)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 22, 2018
1 parent af8a635 commit 81ff6f8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/TemplateWriterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,28 @@ test("fileSlug should exist in a collection", async t => {
let templates = await mapEntry.template.getRenderedTemplates(mapEntry.data);
t.is(templates[0].templateContent.trim(), "fileSlug:/dog1/:dog1");
});

// TODO
test.skip("renderData should exist and be resolved in a collection (Issue #289)", async t => {
let tw = new TemplateWriter(
"./test/stubs/collection-renderdata",
"./test/stubs/collection-renderdata/_site",
["njk"]
);

let paths = await tw._getAllPaths();
let templateMap = await tw._createTemplateMap(paths);
await templateMap.cache();

let collectionsData = await templateMap.getCollectionsData();
t.is(collectionsData.dog.length, 1);

let mapEntry = templateMap.getMapEntryForPath(
"./test/stubs/collection-renderdata/template.njk"
);
t.truthy(mapEntry);
t.is(mapEntry.inputPath, "./test/stubs/collection-renderdata/template.njk");

let templates = await mapEntry.template.getRenderedTemplates(mapEntry.data);
t.is(templates[0].templateContent.trim(), "Test Title");
});
7 changes: 7 additions & 0 deletions test/stubs/collection-renderdata/dog.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
key1: value1
renderData:
key2: value2-{{ key1 }}.css
tags:
- dog
---
1 change: 1 addition & 0 deletions test/stubs/collection-renderdata/template.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% for post in collections.dog %}{{ post.data.renderData.key2 }}{% endfor %}

0 comments on commit 81ff6f8

Please sign in to comment.