test with deno and bun

This commit is contained in:
Nebel 2024-09-03 09:50:43 +09:00
parent 628cc0bdee
commit 8d6c191978
Signed by: nebel
GPG key ID: 79807D08C6EF6460
9 changed files with 120 additions and 1 deletions

View file

@ -1,7 +1,7 @@
name: test name: test
on: push on: push
jobs: jobs:
nodejs: node:
name: Node.js v${{ matrix.node-version }} name: Node.js v${{ matrix.node-version }}
strategy: strategy:
matrix: matrix:
@ -18,3 +18,25 @@ jobs:
cache: npm cache: npm
- run: npm ci - run: npm ci
- run: npm test - run: npm test
deno:
name: Deno
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: latest
- run: deno task test
working-directory: runtime/deno
bun:
name: Bun
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun test
working-directory: runtime/bun

View file

@ -18,6 +18,9 @@ yarn add websri
# pnpm # pnpm
pnpm install websri pnpm install websri
# deno
deno add npm:websri
# bun # bun
bun install websri bun install websri
``` ```

View file

@ -0,0 +1,12 @@
import { expect, test } from "bun:test";
import { createIntegrityMetadata } from "../../src/index.ts";
test("createIntegrityMetadata()", async () => {
const res = new Response("Hello, world!");
const data = await res.arrayBuffer();
const integrityMetadata = await createIntegrityMetadata("sha256", data);
expect(integrityMetadata.toString()).toBe(
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
);
});

BIN
runtime/bun/bun.lockb Executable file

Binary file not shown.

8
runtime/bun/package.json Normal file
View file

@ -0,0 +1,8 @@
{
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}

27
runtime/bun/tsconfig.json Normal file
View file

@ -0,0 +1,27 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}

8
runtime/deno/deno.json Normal file
View file

@ -0,0 +1,8 @@
{
"tasks": {
"test": "deno test --no-check"
},
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.3"
}
}

26
runtime/deno/deno.lock generated Normal file
View file

@ -0,0 +1,26 @@
{
"version": "3",
"packages": {
"specifiers": {
"jsr:@std/assert@^1.0.3": "jsr:@std/assert@1.0.3",
"jsr:@std/internal@^1.0.2": "jsr:@std/internal@1.0.2"
},
"jsr": {
"@std/assert@1.0.3": {
"integrity": "b0d03ce1ced880df67132eea140623010d415848df66f6aa5df76507ca7c26d8",
"dependencies": [
"jsr:@std/internal@^1.0.2"
]
},
"@std/internal@1.0.2": {
"integrity": "f4cabe2021352e8bfc24e6569700df87bf070914fc38d4b23eddd20108ac4495"
}
}
},
"remote": {},
"workspace": {
"dependencies": [
"jsr:@std/assert@^1.0.3"
]
}
}

View file

@ -0,0 +1,13 @@
import { assertEquals } from "@std/assert";
import { createIntegrityMetadata } from "../../src/index.ts";
Deno.test("createIntegrityMetadata()", async () => {
const res = new Response("Hello, world!");
const data = await res.arrayBuffer();
const integrityMetadata = await createIntegrityMetadata("sha256", data);
assertEquals(
integrityMetadata.toString(),
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
);
});