-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
136 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
dist | ||
node_modules | ||
coverage | ||
deno.lock | ||
.DS_Store | ||
.idea | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect, test } from 'bun:test' | ||
|
||
test('bun integration test', async () => { | ||
const process = Bun.spawn(['bun', 'run', './index.ts'], { | ||
stdin: 'inherit', | ||
cwd: import.meta.dir, | ||
}) | ||
await Bun.sleep(1000) | ||
|
||
const req = new Request('http://localhost:8124') | ||
req.headers.set('accept-language', 'en-US,en;q=0.9,ja;q=0.8') | ||
const res = await fetch(req) | ||
await Bun.sleep(1000) | ||
|
||
expect(await res.text()).toBe('detect locale: en-US') | ||
process.kill() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"tasks": { | ||
"dev": "deno run --watch main.ts" | ||
"dev": "deno run --watch main.ts", | ||
"test": "deno test --allow-read=$(which deno) --allow-run --allow-net ./deno.spec.ts" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { assertEquals } from 'https://deno.land/[email protected]/assert/mod.ts' | ||
|
||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) | ||
|
||
Deno.test('deno integration test', async () => { | ||
const command = new Deno.Command(Deno.execPath(), { | ||
stdout: 'null', | ||
args: [ | ||
'run', | ||
'--allow-net', | ||
'./main.ts', | ||
], | ||
}) | ||
const process = command.spawn() | ||
await sleep(1000) | ||
|
||
const req = new Request('http://localhost:8125') | ||
req.headers.set('accept-language', 'en-US,en;q=0.9,ja;q=0.8') | ||
const res = await fetch(req) | ||
await sleep(1000) | ||
|
||
assertEquals('detect accpect-language: en-US,en,ja', await res.text()) | ||
|
||
process.kill('SIGINT') | ||
await process.status | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import assert from 'node:assert' | ||
import test from 'node:test' | ||
import { spawn } from 'node:child_process' | ||
import { fetch } from 'ofetch' | ||
|
||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) | ||
|
||
test('node integration test', async () => { | ||
const child = spawn('npx', ['tsx', './index.ts'], { cwd: process.cwd(), stdio: 'inherit' }) | ||
await sleep(1000) | ||
|
||
const req = new Request('http://localhost:8123') | ||
req.headers.set('accept-language', 'en-US,en;q=0.9,ja;q=0.8') | ||
const res = await fetch(req) | ||
await sleep(1000) | ||
|
||
assert.deepEqual('detect accpect-language: en-US,en,ja', await res.text()) | ||
child.kill('SIGINT') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": ["./tsconfig.json"], | ||
"exclude": ["./playground"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from 'vitest/config' | ||
import config from './vitest.config.ts' | ||
|
||
export default defineConfig({ | ||
...config, | ||
test: { | ||
...config.test, | ||
typecheck: { | ||
tsconfig: './tsconfig.vitest.json', | ||
}, | ||
}, | ||
}) |