add tests

This commit is contained in:
Valere
2026-03-26 18:14:51 +01:00
parent 8f38ecac2e
commit 1eabb0f0aa
2 changed files with 41 additions and 8 deletions

View File

@@ -173,7 +173,8 @@ async function getAvatarFromServer(
return blob;
}
async function getAvatarFromWidgetAPI(
// export for testing
export async function getAvatarFromWidgetAPI(
api: WidgetApi,
src: string,
): Promise<Blob> {
@@ -185,12 +186,10 @@ async function getAvatarFromWidgetAPI(
return file;
} else if (typeof file === "string") {
// it is a base64 string
const bytes = Uint8Array.from(atob(file), (c) =>
c.charCodeAt(0),
);
const bytes = Uint8Array.from(atob(file), (c) => c.charCodeAt(0));
return new Blob([bytes]);
}
throw new Error("Downloaded file format is not supported: " + typeof file + "");
throw new Error(
"Downloaded file format is not supported: " + typeof file + "",
);
}