fix is_toggled test

This commit is contained in:
dswbx
2025-03-14 11:45:02 +01:00
parent 6015acb914
commit 181443b320
2 changed files with 2 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ describe("env", () => {
expect(is_toggled(1)).toBe(true);
expect(is_toggled(0)).toBe(false);
expect(is_toggled("anything else")).toBe(false);
expect(is_toggled(undefined, true)).toBe(true);
});
test("env()", () => {

View File

@@ -1,7 +1,7 @@
export type Env = {};
export const is_toggled = (given: unknown, fallback?: boolean): boolean => {
return typeof given === "string" ? [1, "1", "true"].includes(given) : Boolean(fallback);
return typeof given === "string" ? [1, "1", "true"].includes(given) : Boolean(given || fallback);
};
export function isDebug(): boolean {