fix, rm early return
This commit is contained in:
@@ -57,6 +57,23 @@ describe("Image", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("resizes images that fit the byte limit but exceed dimension limits", () =>
|
||||
Effect.gen(function* () {
|
||||
const photon = yield* Effect.promise(() => import("@silvia-odwyer/photon-node"))
|
||||
const source = new photon.PhotonImage(new Uint8Array(Array.from({ length: 9_000 * 4 }, () => 255)), 9_000, 1)
|
||||
const image = yield* Image.Service
|
||||
const result = yield* image.normalize(part("image/png", Buffer.from(source.get_bytes()).toString("base64")))
|
||||
const resized = photon.PhotonImage.new_from_byteslice(
|
||||
Buffer.from(result.url.slice(result.url.indexOf(";base64,") + ";base64,".length), "base64"),
|
||||
)
|
||||
|
||||
source.free()
|
||||
expect(resized.get_width()).toBeLessThanOrEqual(2_000)
|
||||
expect(resized.get_height()).toBeLessThanOrEqual(2_000)
|
||||
resized.free()
|
||||
}),
|
||||
)
|
||||
|
||||
tiny.effect("fails with a typed size error when no resized candidate fits", () =>
|
||||
Effect.gen(function* () {
|
||||
const photon = yield* Effect.promise(() => import("@silvia-odwyer/photon-node"))
|
||||
|
||||
Reference in New Issue
Block a user