diff --git a/actions/setup/js/is_truthy.test.cjs b/actions/setup/js/is_truthy.test.cjs index 5418b5c70b..fd9ea05a4f 100644 --- a/actions/setup/js/is_truthy.test.cjs +++ b/actions/setup/js/is_truthy.test.cjs @@ -1,36 +1,61 @@ -import { describe, it as test, expect } from "vitest"; +import { describe, it, expect } from "vitest"; + const { isTruthy } = require("./is_truthy.cjs"); + describe("is_truthy.cjs", () => { describe("isTruthy", () => { - (test("should return false for empty string", () => { - expect(isTruthy("")).toBe(!1); - }), - test('should return false for "false"', () => { - (expect(isTruthy("false")).toBe(!1), expect(isTruthy("FALSE")).toBe(!1), expect(isTruthy("False")).toBe(!1)); - }), - test('should return false for "0"', () => { - expect(isTruthy("0")).toBe(!1); - }), - test('should return false for "null"', () => { - (expect(isTruthy("null")).toBe(!1), expect(isTruthy("NULL")).toBe(!1)); - }), - test('should return false for "undefined"', () => { - (expect(isTruthy("undefined")).toBe(!1), expect(isTruthy("UNDEFINED")).toBe(!1)); - }), - test('should return true for "true"', () => { - (expect(isTruthy("true")).toBe(!0), expect(isTruthy("TRUE")).toBe(!0)); - }), - test("should return true for any non-falsy string", () => { - (expect(isTruthy("yes")).toBe(!0), expect(isTruthy("1")).toBe(!0), expect(isTruthy("hello")).toBe(!0)); - }), - test("should trim whitespace", () => { - (expect(isTruthy(" false ")).toBe(!1), expect(isTruthy(" true ")).toBe(!0), expect(isTruthy(" ")).toBe(!1)); - }), - test("should handle numeric strings", () => { - (expect(isTruthy("0")).toBe(!1), expect(isTruthy("1")).toBe(!0), expect(isTruthy("123")).toBe(!0), expect(isTruthy("-1")).toBe(!0)); - }), - test("should handle case-insensitive falsy values", () => { - (expect(isTruthy("FaLsE")).toBe(!1), expect(isTruthy("NuLl")).toBe(!1), expect(isTruthy("UnDeFiNeD")).toBe(!1)); - })); + it("should return false for empty string", () => { + expect(isTruthy("")).toBe(false); + }); + + it('should return false for "false" (case-insensitive)', () => { + expect(isTruthy("false")).toBe(false); + expect(isTruthy("FALSE")).toBe(false); + expect(isTruthy("False")).toBe(false); + }); + + it('should return false for "0"', () => { + expect(isTruthy("0")).toBe(false); + }); + + it('should return false for "null" (case-insensitive)', () => { + expect(isTruthy("null")).toBe(false); + expect(isTruthy("NULL")).toBe(false); + }); + + it('should return false for "undefined" (case-insensitive)', () => { + expect(isTruthy("undefined")).toBe(false); + expect(isTruthy("UNDEFINED")).toBe(false); + }); + + it('should return true for "true" (case-insensitive)', () => { + expect(isTruthy("true")).toBe(true); + expect(isTruthy("TRUE")).toBe(true); + }); + + it("should return true for any non-falsy string", () => { + expect(isTruthy("yes")).toBe(true); + expect(isTruthy("1")).toBe(true); + expect(isTruthy("hello")).toBe(true); + }); + + it("should trim whitespace", () => { + expect(isTruthy(" false ")).toBe(false); + expect(isTruthy(" true ")).toBe(true); + expect(isTruthy(" ")).toBe(false); + }); + + it("should handle numeric strings", () => { + expect(isTruthy("0")).toBe(false); + expect(isTruthy("1")).toBe(true); + expect(isTruthy("123")).toBe(true); + expect(isTruthy("-1")).toBe(true); + }); + + it("should handle case-insensitive falsy values", () => { + expect(isTruthy("FaLsE")).toBe(false); + expect(isTruthy("NuLl")).toBe(false); + expect(isTruthy("UnDeFiNeD")).toBe(false); + }); }); });