From 1fa99f0815ad2ec1ba82e93c77150dc10735aab2 Mon Sep 17 00:00:00 2001 From: gonzaloriestra <14979109+gonzaloriestra@users.noreply.github.com> Date: Thu, 16 Jul 2026 00:19:20 +0000 Subject: [PATCH] [Tests] Add unit tests for isTruthy Add comprehensive unit tests for the `isTruthy` utility function in `packages/cli-kit/src/public/node/context/utilities.ts`. These tests cover various truthy patterns ('1', 'true', 'yes') with case-insensitivity, and several falsy scenarios including undefined, empty strings, and '0'. --- .../src/public/node/context/utilities.test.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/cli-kit/src/public/node/context/utilities.test.ts diff --git a/packages/cli-kit/src/public/node/context/utilities.test.ts b/packages/cli-kit/src/public/node/context/utilities.test.ts new file mode 100644 index 00000000000..98e7ccbc57d --- /dev/null +++ b/packages/cli-kit/src/public/node/context/utilities.test.ts @@ -0,0 +1,48 @@ +import {isTruthy} from './utilities.js' +import {describe, expect, test} from 'vitest' + +describe('isTruthy', () => { + test('returns true for "1"', () => { + expect(isTruthy('1')).toBe(true) + }) + + test('returns true for "true"', () => { + expect(isTruthy('true')).toBe(true) + }) + + test('returns true for "TRUE"', () => { + expect(isTruthy('TRUE')).toBe(true) + }) + + test('returns true for "yes"', () => { + expect(isTruthy('yes')).toBe(true) + }) + + test('returns true for "YES"', () => { + expect(isTruthy('YES')).toBe(true) + }) + + test('returns false for "0"', () => { + expect(isTruthy('0')).toBe(false) + }) + + test('returns false for "false"', () => { + expect(isTruthy('false')).toBe(false) + }) + + test('returns false for "no"', () => { + expect(isTruthy('no')).toBe(false) + }) + + test('returns false for undefined', () => { + expect(isTruthy(undefined)).toBe(false) + }) + + test('returns false for an empty string', () => { + expect(isTruthy('')).toBe(false) + }) + + test('returns false for a random string', () => { + expect(isTruthy('random')).toBe(false) + }) +})