CI / quality (push) Failing after 6m22s
Implements Max_Code_Quality_CICD_Production.md: TypeScript strict mode, ESLint flat config with type-checking and security plugin, Prettier, Husky + lint-staged, Vitest with 80%+ coverage (473 tests), Playwright e2e, Electron security hardening (contextIsolation, CSP, IPC validation), electron-builder + electron-updater, Dockerfile, Gitea Actions CI/release workflows, and SonarQube docker-compose setup. Also fixes two real bugs found while writing tests: unawaited clipboard promises and a mermaid container ref timing issue in CoachDrawingView. Fixes lint-staged on Windows/Node 24 by invoking eslint/prettier via `node <bin>.js` instead of their .cmd shims, which Node's child_process now refuses to spawn without shell:true. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
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()
|
|
})
|
|
})
|