Skip to content

Commit

Permalink
Attempt with dryRun
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Apr 20, 2024
1 parent fd6619c commit 6039bca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@11ty/eleventy-plugin-webc": "^0.11.2",
"ava": "^6.1.2",
"eslint": "^8.56.0",
"fs-extra": "^11.2.0",
"pixelmatch": "^5.3.0"
},
"ava": {
Expand Down
22 changes: 13 additions & 9 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require("path");
const test = require("ava");
const fs = require("fs-extra");
const fs = require("fs");
const { URL } = require("url");
const eleventyImage = require("../");
const sharp = require("sharp");
Expand Down Expand Up @@ -526,32 +526,36 @@ test("Keep a cache, don’t reuse with same file names and different options", a
});

test("Keep a cache, don’t reuse with if the image changes, check promise equality", async t => {
fs.copySync("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg");
fs.copyFileSync("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg");

let promise1 = eleventyImage("./test/generated-modify-bio.jpg", {
outputDir: "./test/img/"
outputDir: "./test/img/",
dryRun: true,
});

fs.copySync("./test/modify-bio-grayscale.jpg", "./test/generated-modify-bio.jpg");
fs.copyFileSync("./test/modify-bio-grayscale.jpg", "./test/generated-modify-bio.jpg");

let promise2 = eleventyImage("./test/generated-modify-bio.jpg", {
outputDir: "./test/img/"
outputDir: "./test/img/",
dryRun: true,
});

t.not(promise1, promise2);
});

test("Keep a cache, don’t reuse with if the image changes, check output", async t => {
fs.copySync("./test/modify2-bio-original.jpg", "./test/generated-modify2-bio.jpg");
fs.copyFileSync("./test/modify2-bio-original.jpg", "./test/generated-modify2-bio.jpg");

let stats1 = await eleventyImage("./test/generated-modify2-bio.jpg", {
outputDir: "./test/img/"
outputDir: "./test/img/",
dryRun: true
});

fs.copySync("./test/modify2-bio-grayscale.jpg", "./test/generated-modify2-bio.jpg");
fs.copyFileSync("./test/modify2-bio-grayscale.jpg", "./test/generated-modify2-bio.jpg");

let stats2 = await eleventyImage("./test/generated-modify2-bio.jpg", {
outputDir: "./test/img/"
outputDir: "./test/img/",
dryRun: true
});

t.notDeepEqual(stats1, stats2);
Expand Down

0 comments on commit 6039bca

Please sign in to comment.