|
1 | 1 | import { describe, expect, test } from "bun:test"; |
2 | 2 |
|
3 | 3 | import { EdgeEnvKeyError } from "../errors.js"; |
4 | | -import { Bindings } from "../types.js"; |
| 4 | +import { Environment } from "../types.js"; |
5 | 5 | import { Env } from "./env.js"; |
6 | 6 |
|
7 | 7 | describe(Env.name, () => { |
8 | | - let bindings = { KEY: "value" } as unknown as Bindings; |
| 8 | + let environment = { KEY: "value" } as unknown as Environment; |
9 | 9 |
|
10 | 10 | test("#constructor", () => { |
11 | | - let env = new Env(bindings); |
| 11 | + let env = new Env(environment); |
12 | 12 | expect(env).toBeInstanceOf(Env); |
13 | 13 | }); |
14 | 14 |
|
15 | | - test("#constructor with missing bindings", () => { |
| 15 | + test("#constructor with missing environment", () => { |
16 | 16 | // @ts-expect-error - Testing invalid input |
17 | 17 | expect(() => new Env(undefined)).toThrow(); |
18 | 18 | }); |
19 | 19 |
|
20 | 20 | test("#fetch", () => { |
21 | | - let env = new Env(bindings); |
| 21 | + let env = new Env(environment); |
22 | 22 | expect(env.fetch("KEY")).toBe("value"); |
23 | 23 | }); |
24 | 24 |
|
25 | 25 | test("#fetch with fallback", () => { |
26 | | - let env = new Env(bindings); |
| 26 | + let env = new Env(environment); |
27 | 27 | expect(env.fetch("OPTIONAL", "fallback")).toBe("fallback"); |
28 | 28 | }); |
29 | 29 |
|
30 | 30 | test("#fetch with missing", () => { |
31 | | - let env = new Env(bindings); |
| 31 | + let env = new Env(environment); |
32 | 32 | expect(() => env.fetch("OPTIONAL")).toThrow(EdgeEnvKeyError); |
33 | 33 | }); |
34 | 34 | }); |
35 | 35 |
|
36 | | -// Overwrite Bindings on this file |
| 36 | +// Overwrite Environment on this file |
37 | 37 | declare module "../types.js" { |
38 | | - interface Bindings { |
| 38 | + interface Environment { |
39 | 39 | KEY: string; |
40 | 40 | OPTIONAL?: string; |
41 | 41 | } |
|
0 commit comments