From 89fd4a2e549f5a9a9061c6e8891ee128110389fa Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 1 Jul 2021 16:27:43 -0500 Subject: [PATCH] Move a few tests --- test/TemplateTest.js | 64 -------------------------------- test/TemplateTest_Permalink.js | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/test/TemplateTest.js b/test/TemplateTest.js index 8c590884a..2fe3b499a 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -593,70 +593,6 @@ test("Clone the template", async (t) => { t.is(cloned.extensionMap, tmpl.extensionMap); }); -test("Permalink with variables!", async (t) => { - let tmpl = getNewTemplate( - "./test/stubs/permalinkdata.njk", - "./test/stubs/", - "./dist" - ); - - t.is(await tmpl.getOutputPath(), "./dist/subdir/slug-candidate/index.html"); -}); - -test("Permalink with variables and JS front matter!", async (t) => { - let tmpl = getNewTemplate( - "./test/stubs/permalinkdata-jsfn.njk", - "./test/stubs/", - "./dist" - ); - - t.is(await tmpl.getOutputPath(), "./dist/subdir/slug/index.html"); -}); - -// This is broken right now, permalink must use the same template language as the template -test.skip("Use a JavaScript function for permalink in any template language", async (t) => { - let tmpl = getNewTemplate( - "./test/stubs/permalinkdata-jspermalinkfn.njk", - "./test/stubs/", - "./dist" - ); - - t.is(await tmpl.getOutputPath(), "./dist/subdir/slug/index.html"); -}); - -test("Permalink with dates!", async (t) => { - let tmpl = getNewTemplate( - "./test/stubs/permalinkdate.liquid", - "./test/stubs/", - "./dist" - ); - - t.is(await tmpl.getOutputPath(), "./dist/2016/01/01/index.html"); -}); - -test("Permalink with dates on file name regex!", async (t) => { - let tmpl = getNewTemplate( - "./test/stubs/2016-02-01-permalinkdate.liquid", - "./test/stubs/", - "./dist" - ); - - t.is(await tmpl.getOutputPath(), "./dist/2016/02/01/index.html"); -}); - -test("Reuse permalink in directory specific data file", async (t) => { - let eleventyConfig = new TemplateConfig(); - let dataObj = new TemplateData("./test/stubs/", eleventyConfig); - let tmpl = getNewTemplate( - "./test/stubs/reuse-permalink/test1.liquid", - "./test/stubs/", - "./dist", - dataObj - ); - - t.is(await tmpl.getOutputPath(), "./dist/2016/01/01/index.html"); -}); - test("mapDataAsRenderedTemplates", async (t) => { let tmpl = getNewTemplate( "./test/stubs/default.ejs", diff --git a/test/TemplateTest_Permalink.js b/test/TemplateTest_Permalink.js index 71fc79683..69ad7236a 100644 --- a/test/TemplateTest_Permalink.js +++ b/test/TemplateTest_Permalink.js @@ -1,5 +1,7 @@ const test = require("ava"); const fs = require("fs"); +const TemplateConfig = require("../src/TemplateConfig"); +const TemplateData = require("../src/TemplateData"); const getNewTemplate = require("./_getNewTemplateForTests"); @@ -122,3 +124,69 @@ test("Disable dynamic permalinks", async (t) => { t.is(await tmpl.getOutputLink(), "/{{justastring}}/index.html"); t.is(await tmpl.getOutputHref(), "/{{justastring}}/"); }); + + +test("Permalink with variables!", async (t) => { + let tmpl = getNewTemplate( + "./test/stubs/permalinkdata.njk", + "./test/stubs/", + "./dist" + ); + + t.is(await tmpl.getOutputPath(), "./dist/subdir/slug-candidate/index.html"); +}); + +test("Permalink with variables and JS front matter!", async (t) => { + let tmpl = getNewTemplate( + "./test/stubs/permalinkdata-jsfn.njk", + "./test/stubs/", + "./dist" + ); + + t.is(await tmpl.getOutputPath(), "./dist/subdir/slug/index.html"); +}); + +// This is broken right now, permalink must use the same template language as the template +test.skip("Use a JavaScript function for permalink in any template language", async (t) => { + let tmpl = getNewTemplate( + "./test/stubs/permalinkdata-jspermalinkfn.njk", + "./test/stubs/", + "./dist" + ); + + t.is(await tmpl.getOutputPath(), "./dist/subdir/slug/index.html"); +}); + +test("Permalink with dates!", async (t) => { + let tmpl = getNewTemplate( + "./test/stubs/permalinkdate.liquid", + "./test/stubs/", + "./dist" + ); + + t.is(await tmpl.getOutputPath(), "./dist/2016/01/01/index.html"); +}); + +test("Permalink with dates on file name regex!", async (t) => { + let tmpl = getNewTemplate( + "./test/stubs/2016-02-01-permalinkdate.liquid", + "./test/stubs/", + "./dist" + ); + + t.is(await tmpl.getOutputPath(), "./dist/2016/02/01/index.html"); +}); + +test("Reuse permalink in directory specific data file", async (t) => { + let eleventyConfig = new TemplateConfig(); + let dataObj = new TemplateData("./test/stubs/", eleventyConfig); + let tmpl = getNewTemplate( + "./test/stubs/reuse-permalink/test1.liquid", + "./test/stubs/", + "./dist", + dataObj + ); + + t.is(await tmpl.getOutputPath(), "./dist/2016/01/01/index.html"); +}); +