Skip to content

Commit

Permalink
Upgrade minimum version of sharp to 0.32.4
Browse files Browse the repository at this point in the history
Ensure PNG to SVG test assertions are deterministic by
verifying the output of the reverse SVG to PNG roundtrip and
therefore existing thresholds, instead of snapshots of exact bytes.
  • Loading branch information
lovell authored and andy128k committed Jul 25, 2023
1 parent 6ccc91b commit a73e092
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 51 deletions.
161 changes: 115 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@
},
"dependencies": {
"escape-html": "^1.0.3",
"sharp": "^0.32.0",
"sharp": "^0.32.4",
"xml2js": "^0.5.0"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/preset-env": "^7.19.4",
"@babel/preset-typescript": "^7.18.6",
"@types/escape-html": "^1.0.2",
"@types/sharp": "^0.31.0",
"@types/xml2js": "^0.4.11",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 31 additions & 1 deletion test/__snapshots__/svgOutput.test.js.snap

Large diffs are not rendered by default.

27 changes: 25 additions & 2 deletions test/svgOutput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test("should reuse svg as a favicon", async () => {
});

test("should generate svg favicon", async () => {
expect.assertions(1);
expect.assertions(2);

const result = await favicons(logo_png, {
icons: {
Expand All @@ -32,5 +32,28 @@ test("should generate svg favicon", async () => {
},
});

await expect(result).toMatchFaviconsSnapshot();
const svg = result.images[0].contents;
const deterministicSvg = Buffer.from(
svg.toString().replace(/png;base64,[^"]+/, "")
);
await expect({
...result,
images: [
{
...result.images[0],
contents: deterministicSvg,
},
],
}).toMatchFaviconsSnapshot();

const roundtripResult = await favicons(svg, {
icons: {
android: false,
appleIcon: false,
appleStartup: false,
windows: false,
yandex: false,
},
});
await expect(roundtripResult).toMatchFaviconsSnapshot();
});

0 comments on commit a73e092

Please sign in to comment.