import { describe, it, expect } from 'vitest' import { num, str, strOrUndefined } from '../../src/main/coach/presets/utils' describe('num()', () => { it('should parse a numeric value within range', () => { expect(num(5, 0, 0, 10)).toBe(5) }) it('should return the fallback for a non-finite value', () => { expect(num('abc', 42)).toBe(42) expect(num(undefined, 42)).toBe(42) expect(num(NaN, 42)).toBe(42) }) it('should clamp a value above the max', () => { expect(num(100, 0, 0, 10)).toBe(10) }) it('should clamp a value below the min', () => { expect(num(-100, 0, 0, 10)).toBe(0) }) }) describe('str()', () => { it('should return the trimmed string when given a non-empty string', () => { expect(str(' hello ')).toBe('hello') }) it('should return the fallback for a non-string or blank value', () => { expect(str(42)).toBe('') expect(str(' ')).toBe('') expect(str(undefined, 'defaut')).toBe('defaut') }) }) describe('strOrUndefined()', () => { it('should return the trimmed string when given a non-empty string', () => { expect(strOrUndefined(' hello ')).toBe('hello') }) it('should return undefined for a non-string or blank value', () => { expect(strOrUndefined(42)).toBeUndefined() expect(strOrUndefined(' ')).toBeUndefined() }) })