fix: readEnvVariable throws error when variable is string
This commit is contained in:
@@ -3,10 +3,27 @@ import { describe, expect, it } from "bun:test";
|
||||
import { readEnvVariable } from "./readEnvVariable";
|
||||
|
||||
describe("readEnvVariable", () => {
|
||||
it("env & variable defined, returns env value", () => {
|
||||
expect(
|
||||
readEnvVariable<boolean>({ ENABLE_ANIFY: "false" }, "ENABLE_ANIFY"),
|
||||
).toBe(false);
|
||||
describe("env & variable defined", () => {
|
||||
it("returns boolean", () => {
|
||||
expect(
|
||||
readEnvVariable<boolean>({ ENABLE_ANIFY: "false" }, "ENABLE_ANIFY"),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("returns string", () => {
|
||||
expect(
|
||||
readEnvVariable<string>(
|
||||
{ QSTASH_TOKEN: "ehf73g8gyriuvnieojwicbg83hc" },
|
||||
"QSTASH_TOKEN",
|
||||
),
|
||||
).toBe("ehf73g8gyriuvnieojwicbg83hc");
|
||||
});
|
||||
|
||||
it("returns number", () => {
|
||||
expect(
|
||||
readEnvVariable<number>({ NUM_RETRIES: "123" }, "NUM_RETRIES"),
|
||||
).toBe(123);
|
||||
});
|
||||
});
|
||||
|
||||
it("env defined but variable not defined, returns default value", () => {
|
||||
|
||||
Reference in New Issue
Block a user