diff --git a/test/EleventyTest.js b/test/EleventyTest.js index e50dce3bd..a385cfdc3 100644 --- a/test/EleventyTest.js +++ b/test/EleventyTest.js @@ -3,6 +3,7 @@ const Eleventy = require("../src/Eleventy"); const EleventyWatchTargets = require("../src/EleventyWatchTargets"); const TemplateConfig = require("../src/TemplateConfig"); const DateGitLastUpdated = require("../src/Util/DateGitLastUpdated"); +const normalizeNewLines = require("./Util/normalizeNewLines"); test("Eleventy, defaults inherit from config", async (t) => { let elev = new Eleventy(); @@ -424,3 +425,31 @@ test("#142: date 'git Last Modified' populates page.date", async (t) => { let comparisonDate = DateGitLastUpdated("./test/stubs-142/index.njk"); t.is(result.content.trim(), "" + comparisonDate.getTime()); }); + +test("Liquid shortcode with multiple arguments(issue #2348)", async (t) => { + // NOTE issue #2348 was only active when you were processing multiple templates at the same time. + + let elev = new Eleventy("./test/stubs-2367/", "./test/stubs-2367/_site", { + config: function (eleventyConfig) { + eleventyConfig.addShortcode("simplelink", function (...args) { + return JSON.stringify(args); + }); + }, + }); + + let arr = [ + "layout", + "/mylayout", + "layout", + "/mylayout", + "layout", + "/mylayout", + ]; + let str = normalizeNewLines(`${JSON.stringify(arr)} +${JSON.stringify(arr)}`); + let results = await elev.toJSON(); + t.is(results.length, 2); + let content = results.map((entry) => entry.content).sort(); + t.is(normalizeNewLines(content[0]), str); + t.is(normalizeNewLines(content[1]), str); +}); diff --git a/test/TemplateTest.js b/test/TemplateTest.js index c25802cb9..11aba5cfa 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -293,45 +293,6 @@ test("One Layout (_layoutContent deprecated but supported)", async (t) => { t.is(data.keylayout, "valuelayout"); }); -test("Liquid shortcode with multiple arguments(issue #2348)", async (t) => { - // NOTE issue #2348 was only active when you were processing multiple templates at the same time. - - let eleventyConfig = new TemplateConfig(); - eleventyConfig.userConfig.addShortcode("simplelink", function (text, url) { - return `${text} (${url})`; - }); - - let dataObj = new TemplateData("./test/stubs/", eleventyConfig); - - let tmpl = getNewTemplate( - "./test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid", - "./test/stubs/", - "dist", - dataObj, - null, - eleventyConfig - ); - - t.is( - (await tmpl.getFrontMatter()).data[tmpl.config.keys.layout], - "layoutLiquid.liquid" - ); - - let data = await tmpl.getData(); - t.is(data[tmpl.config.keys.layout], "layoutLiquid.liquid"); - - t.is( - normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))), - `
-

Hello.

- world (/somepage) -
` - ); - - t.is(data.keymain, "valuemain"); - t.is(data.keylayout, "valuelayout"); -}); - test("One Layout (liquid test)", async (t) => { let eleventyConfig = new TemplateConfig(); let dataObj = new TemplateData("./test/stubs/", eleventyConfig); diff --git a/test/stubs-2367/_includes/layout.liquid b/test/stubs-2367/_includes/layout.liquid new file mode 100644 index 000000000..6d74116ff --- /dev/null +++ b/test/stubs-2367/_includes/layout.liquid @@ -0,0 +1,6 @@ +--- +text: layout +url: "/mylayout" +--- +{% simplelink text url text url text url %} +{% simplelink text, url, text, url, text, url %} \ No newline at end of file diff --git a/test/stubs-2367/templateWithLiquidShortcodeMultipleArguments-template2.liquid b/test/stubs-2367/templateWithLiquidShortcodeMultipleArguments-template2.liquid new file mode 100644 index 000000000..716072b7f --- /dev/null +++ b/test/stubs-2367/templateWithLiquidShortcodeMultipleArguments-template2.liquid @@ -0,0 +1,3 @@ +--- +layout: layout.liquid +--- \ No newline at end of file diff --git a/test/stubs-2367/templateWithLiquidShortcodeMultipleArguments.liquid b/test/stubs-2367/templateWithLiquidShortcodeMultipleArguments.liquid new file mode 100644 index 000000000..716072b7f --- /dev/null +++ b/test/stubs-2367/templateWithLiquidShortcodeMultipleArguments.liquid @@ -0,0 +1,3 @@ +--- +layout: layout.liquid +--- \ No newline at end of file diff --git a/test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid b/test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid deleted file mode 100644 index ca2eefe84..000000000 --- a/test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid +++ /dev/null @@ -1,9 +0,0 @@ ---- -layout: layoutLiquid.liquid -keymain: valuemain -title: 'Font Aliasing, or How to Rename a Font in CSS' -permalink: /rename-font2/ ---- - -

Hello.

-{% simplelink "world", "/somepage" %} \ No newline at end of file