Skip to content

Add unit tests for color and utils libraries#30

Merged
alekslinde merged 1 commit into
mainfrom
test/unit-tests-color-utils
Jun 11, 2026
Merged

Add unit tests for color and utils libraries#30
alekslinde merged 1 commit into
mainfrom
test/unit-tests-color-utils

Conversation

@alekslinde

Copy link
Copy Markdown
Owner

Summary

  • color.ts and utils.ts had no test coverage despite being used by multiple tools (WCAG contrast checker, tints/shades, color palette, font converter). This adds 59 tests covering all exported pure functions.
  • dl is intentionally excluded — it requires DOM APIs and is untestable in the Node Vitest environment.
  • All 102 tests pass (59 new + 43 existing font-converter tests).

Test plan

  • npm test → all 102 tests green
  • fmtBytes — byte/KB/MB boundary values produce correct formatted strings
  • baseName / extOf — multi-part names, hidden files, no-extension inputs
  • hexToRgb / rgbToHex — 3-digit shorthand expansion, round-trip fidelity
  • rgbToHsl / hslToRgb — primary colors, black, white, grey, round-trip within rounding tolerance
  • relativeLuminance — black=0, white=1, output in [0,1]
  • contrastRatio — black/white ≈21:1, symmetry, WCAG AA threshold (≥4.5)
  • isLight — white/yellow light; black/navy dark
  • isValidHex — accepts #rgb and #rrggbb; rejects missing hash, wrong length, invalid chars
  • mixColors — t=0 returns first color, t=1 returns second, t=0.5 midpoint, known interpolation value

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
lindetoolbox e532720 Jun 11 2026, 01:54 PM

@alekslinde alekslinde merged commit d16ca4f into main Jun 11, 2026
1 of 2 checks passed
@alekslinde alekslinde deleted the test/unit-tests-color-utils branch June 11, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant