Skip to content

Commit

Permalink
Fix Windows escape paths in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Apr 20, 2024
1 parent 83de20f commit 562978f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion test/test-webc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import test from "ava";
import Eleventy from "@11ty/eleventy";
import eleventyWebcPlugin from "@11ty/eleventy-plugin-webc";
import { eleventyImagePlugin } from "../img.js";
import { normalizeEscapedPaths } from "./util/utils.js";

test("Using <eleventy-image>", async t => {
let elev = new Eleventy( "test/webc/simple.webc", "test/webc/_site", {
Expand Down Expand Up @@ -65,5 +66,5 @@ test("With transform on request during dev mode", async t => {
});

let results = await elev.toJSON();
t.is(results[0].content, `<img loading="lazy" src="/.11ty/image/?src=.%2Ftest%2Fbio-2017.jpg&amp;width=1280&amp;format=jpeg" alt="My ugly mug" width="1280" height="853">`);
t.is(normalizeEscapedPaths(results[0].content), `<img loading="lazy" src="/.11ty/image/?src=.%2Ftest%2Fbio-2017.jpg&amp;width=1280&amp;format=jpeg" alt="My ugly mug" width="1280" height="853">`);
});
3 changes: 2 additions & 1 deletion test/transform-test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import test from "ava";
import Eleventy from "@11ty/eleventy";
import { eleventyImageTransformPlugin } from "../img.js";
import { normalizeEscapedPaths } from "./util/utils.js";

test("Using the transform plugin", async t => {
let elev = new Eleventy( "test", "test/_site", {
Expand Down Expand Up @@ -71,7 +72,7 @@ test("Using the transform plugin with transform on request during dev mode (with
});

let results = await elev.toJSON();
t.is(results[0].content, `<img loading="lazy" src="/.11ty/image/?src=test%2Fbio-2017.jpg&width=1280&format=jpeg" alt="My ugly mug" width="1280" height="853">`);
t.is(normalizeEscapedPaths(results[0].content), `<img loading="lazy" src="/.11ty/image/?src=test%2Fbio-2017.jpg&width=1280&format=jpeg" alt="My ugly mug" width="1280" height="853">`);
});


Expand Down
7 changes: 7 additions & 0 deletions test/util/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function normalizeEscapedPaths(p) {
return p.replaceAll("%5C", "%2F");
}

module.exports = {
normalizeEscapedPaths
};

0 comments on commit 562978f

Please sign in to comment.