websri/test/create-integrity-metadata.ts
Kohei Watanabe c026b150f2
Some checks are pending
test / Node.js v20 (push) Waiting to run
test / Node.js v22 (push) Waiting to run
test / Deno (push) Waiting to run
test / Bun (push) Waiting to run
replace tsup with pkgroll and tsx for bundling
2024-10-02 19:07:50 +09:00

23 lines
825 B
TypeScript

import assert from "node:assert";
import { test } from "node:test";
import { createIntegrityMetadata, IntegrityMetadata } from "../src/index.ts";
test("instantiate a new IntegrityMetadata", async function () {
const res = new Response("Hello, world!");
const data = await res.arrayBuffer();
const integrityMetadata = await createIntegrityMetadata("sha256", data);
assert(integrityMetadata instanceof IntegrityMetadata);
});
test("instantiate with the specified hash algorithm and ArrayBuffer", async function () {
const res = new Response("Hello, world!");
const data = await res.arrayBuffer();
const integrityMetadata = await createIntegrityMetadata("sha256", data);
assert.deepEqual(integrityMetadata, {
alg: "sha256",
val: "MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
opt: [],
});
});