-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly handle fit mode in Bunny.net, Cloudflare and Kontent.ai (
#68) * fix: correctly handle fit mode in Bunny.net, Cloudflare and Kontent.ai * Add note on e2e test * chore: fix tests
- Loading branch information
Showing
12 changed files
with
103 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ jobs: | |
- name: Typecheck | ||
run: deno check mod.ts | ||
- name: Test | ||
run: deno test src/ | ||
run: deno test -A src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
assertEquals, | ||
assertExists, | ||
} from "https://deno.land/std@0.172.0/testing/asserts.ts"; | ||
import examples from "../demo/src/examples.json" assert { type: "json" }; | ||
import { getPixels } from "https://deno.land/x/get_pixels@1.0.0/mod.ts"; | ||
import { transformUrl } from "./transform.ts"; | ||
import type { ImageCdn } from "./types.ts"; | ||
|
||
Deno.test("E2E tests", async (t) => { | ||
for (const [cdn, example] of Object.entries(examples)) { | ||
const [name, url] = example; | ||
await t.step(`${name} resizes an image`, async () => { | ||
const image = transformUrl({ | ||
url, | ||
width: 100, | ||
cdn: cdn as ImageCdn, | ||
}); | ||
|
||
assertExists(image, `Failed to resize ${name} with ${cdn}`); | ||
const { width } = await getPixels(image); | ||
|
||
assertEquals(width, 100); | ||
}); | ||
|
||
// Builder.io handles crop incorrectly at the moment | ||
if (cdn === "builder.io") { | ||
continue; | ||
} | ||
|
||
await t.step(`${name} returns requested aspect ratio`, async () => { | ||
const image = transformUrl({ | ||
url, | ||
width: 100, | ||
height: 50, | ||
cdn: cdn as ImageCdn, | ||
}); | ||
|
||
assertExists(image, `Failed to resize ${name} with ${cdn}`); | ||
|
||
const { width, height } = await getPixels(image); | ||
|
||
assertEquals(width, 100); | ||
assertEquals(height, 50); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters