From a9c6224241e3b3ef03c64a0db9278c94d2a46682 Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Sun, 15 Feb 2026 03:16:16 +0000 Subject: [PATCH] Clean is_truthy.test.cjs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modernize and clean test file for is_truthy: - Remove weird parenthesis patterns and comma operators - Improve test descriptions with context - Properly structure assertions (one assertion per line) - Maintain 10 comprehensive test cases covering all edge cases Test improvements: - All 10 tests passing ✓ - Better readability and maintainability - No logic changes, only code quality improvements Validation checks passed: ✓ Formatting: npm run format:cjs ✓ Linting: npm run lint:cjs ✓ Type checking: npm run typecheck ✓ Tests: npm run test:js -- is_truthy.test.cjs (10/10 passed) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- actions/setup/js/is_truthy.test.cjs | 87 +++++++++++++++++++---------- 1 file changed, 56 insertions(+), 31 deletions(-) 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); + }); }); });