Skip to content

Commit

Permalink
Test for #613 and #3345
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jul 5, 2024
1 parent b76553a commit 922d941
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/EleventyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,3 +1383,29 @@ test("Test input/output conflicts (output overwrites another input), Issue #3327
});
t.true(e.toString().startsWith("DuplicatePermalinkOutputError:"));
});

test("Eleventy data schema has access to custom collections created via API #613 #3345", async (t) => {

let elev = new Eleventy("./test/stubs-virtual/", undefined, {
config: eleventyConfig => {
eleventyConfig.addCollection("userCollection", async function (collection) {
let c = collection.getFilteredByTag("posts");
for(let item of c) {
const frontMatter = await item.template.read();
frontMatter.content = `lol\n${frontMatter.content}`;
item.template.frontMatter = frontMatter;
}
return c;
});

eleventyConfig.addTemplate("home.html", "{% for post in collections.userCollection %}{{ post.content }}{% endfor %}");
eleventyConfig.addTemplate("post.html", "test", { tags: "posts" });
}
});
elev.disableLogger();

let results = await elev.toJSON();
let [home] = results.filter(item => item.url.endsWith("/home/"));
t.truthy(home);
t.is(home.content, "test");
});

0 comments on commit 922d941

Please sign in to comment.