Skip to content

Commit f327db2

Browse files
authored
test: add type tests (#4)
1 parent 30489cc commit f327db2

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

deno.jsonc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
"compilerOptions": {
44
"strict": true,
55
"useUnknownInCatchVariables": true,
6-
"noImplicitOverride": true
6+
"noImplicitOverride": true,
7+
"types": [
8+
"./mod.d.ts"
9+
]
710
},
811
"exclude": [
912
".git"
1013
],
1114
"tasks": {
12-
"test": "deno test -A --allow-none --shuffle --parallel",
15+
"test": "deno check types_test.ts",
1316
"check:types": "deno check **/*.ts",
1417
"check": "deno fmt --check && deno lint && deno task check:types && deno task test"
1518
}

types_test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import {
2+
assertType,
3+
Has,
4+
IsExact,
5+
IsNullable,
6+
} from "https://deno.land/std@0.212.0/testing/types.ts";
7+
8+
// env
9+
{
10+
// get
11+
{
12+
const value = BreezeRuntime.env.get("foo");
13+
14+
assertType<IsNullable<typeof value>>(true);
15+
assertType<Has<typeof value, string>>(true);
16+
}
17+
18+
// toObject
19+
{
20+
const values = BreezeRuntime.env.toObject();
21+
22+
assertType<IsExact<typeof values, Record<string, string | undefined>>>(
23+
true,
24+
);
25+
}
26+
27+
// has
28+
{
29+
const value = BreezeRuntime.env.has("foo");
30+
31+
assertType<IsExact<typeof value, boolean>>(true);
32+
}
33+
}
34+
35+
// plugins
36+
{
37+
// get a plugin
38+
{
39+
const plugin = BreezeRuntime.plugins.kv;
40+
41+
assertType<IsExact<typeof plugin, BreezeRuntime.Plugin>>(true);
42+
}
43+
44+
// getEndpoint
45+
{
46+
const result = BreezeRuntime.plugins.kv.getEndpoint();
47+
48+
assertType<IsExact<typeof result, Promise<URL>>>(true);
49+
}
50+
}
51+
52+
// serveHttp
53+
{
54+
type Params = Parameters<typeof BreezeRuntime.serveHttp>[0];
55+
56+
assertType<
57+
IsExact<Params, (req: Request) => Response | Promise<Response>>
58+
>(true);
59+
}

0 commit comments

Comments
 (0)