mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-11-13 17:08:20 +00:00
test: add download mime, quality verification
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import {
|
||||
expect,
|
||||
type Download,
|
||||
@@ -88,6 +89,18 @@ export async function downloadResultFile(page: Page): Promise<Download> {
|
||||
return download;
|
||||
}
|
||||
|
||||
export async function downloadResultBytes(
|
||||
page: Page,
|
||||
): Promise<{ name: string; bytes: Uint8Array }> {
|
||||
const download = await downloadResultFile(page);
|
||||
const path = await download.path();
|
||||
if (!path) throw new Error("download path is unavailable");
|
||||
return {
|
||||
name: download.suggestedFilename(),
|
||||
bytes: new Uint8Array(await readFile(path)),
|
||||
};
|
||||
}
|
||||
|
||||
export async function downloadResult(page: Page): Promise<string> {
|
||||
return (await downloadResultFile(page)).suggestedFilename();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user