-
-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import test from "ava"; | ||
import Eleventy from "../src/Eleventy.js"; | ||
|
||
test("Empty collections api #3467 (return undefined)", async (t) => { | ||
let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { | ||
config: function (eleventyConfig) { | ||
eleventyConfig.addTemplate("virtual.md", `# Hello`); | ||
|
||
eleventyConfig.addCollection("brokenCollection", function(collection) { | ||
// returns nothing | ||
}); | ||
}, | ||
}); | ||
|
||
let results = await elev.toJSON(); | ||
|
||
t.deepEqual(results.length, 1); | ||
t.deepEqual(results[0].content.trim(), `<h1>Hello</h1>`); | ||
t.deepEqual(results[0].rawInput, `# Hello`); | ||
}); | ||
|
||
test("Empty collections api #3467 (return false)", async (t) => { | ||
let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { | ||
config: function (eleventyConfig) { | ||
eleventyConfig.addTemplate("virtual.md", `# Hello`); | ||
|
||
eleventyConfig.addCollection("brokenCollection", function(collection) { | ||
return false; | ||
}); | ||
}, | ||
}); | ||
|
||
let results = await elev.toJSON(); | ||
|
||
t.deepEqual(results.length, 1); | ||
t.deepEqual(results[0].content.trim(), `<h1>Hello</h1>`); | ||
t.deepEqual(results[0].rawInput, `# Hello`); | ||
}); | ||
|
||
test("Empty collections api #3467 (return empty string)", async (t) => { | ||
let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { | ||
config: function (eleventyConfig) { | ||
eleventyConfig.addTemplate("virtual.md", `# Hello`); | ||
|
||
eleventyConfig.addCollection("brokenCollection", function(collection) { | ||
return ""; | ||
}); | ||
}, | ||
}); | ||
|
||
let results = await elev.toJSON(); | ||
|
||
t.deepEqual(results.length, 1); | ||
t.deepEqual(results[0].content.trim(), `<h1>Hello</h1>`); | ||
t.deepEqual(results[0].rawInput, `# Hello`); | ||
}); |