Skip to content

test: cover design-system color and prefix validators#507

Merged
1nonlypiece merged 1 commit into
Disciplr-Org:mainfrom
Dennis-Ritchie1:test/ds-string-validators-pr
Jun 28, 2026
Merged

test: cover design-system color and prefix validators#507
1nonlypiece merged 1 commit into
Disciplr-Org:mainfrom
Dennis-Ritchie1:test/ds-string-validators-pr

Conversation

@Dennis-Ritchie1

Copy link
Copy Markdown
Contributor

test: cover design-system color and prefix validators

Closes #333

📌 Summary

Adds focused unit-test coverage for the low-level string validators in design-system/src/utils/validators.ts. The existing validators.test.ts covered
isValidColorToken/isValidChartTokens but only lightly touched the primitive validators. This PR adds dedicated boundary tables for them.

🎯 What's covered

  • isValidHexColor — accepts #0A7668; rejects 3-digit (#abc), 8-digit (#0A7668FF), missing #, non-hex chars, empty/whitespace, surrounding whitespace.
  • isValidRgbColor — accepts canonical forms; rejects extra spaces/commas, missing channel, rgba() alpha variant, empty/whitespace.
  • isValidHslColor — accepts canonical forms; rejects missing %, hsla() alpha variant, extra spaces, empty/whitespace.
  • isKebabCase — accepts chart-grid; rejects Chart-Grid (mixed case), chart_grid (underscore), 1chart (leading digit), chart- (trailing hyphen),
    empty/whitespace.
  • hasValidTokenPrefix — accepts each documented prefix (color-, spacing-, typography-, shadow-, radius-, border-, motion-); rejects unknown prefixes
    (chart-foo) and prefix-without-hyphen (color, colorfoo), empty/whitespace.

✅ Results

  • cd design-system && npm test → 53 passed, 5 suites, no regressions.
  • Coverage on validators.ts: 100% statements / branches / functions / lines (target was 95%).

📂 Changes

  • design-system/src/tests/validators.test.ts — appended new boundary-table describe blocks (test-only change; no production code modified).

@1nonlypiece

Copy link
Copy Markdown
Contributor

good to have the color and prefix validators pinned down by tests. merged

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.

Add unit tests for design-system color/RGB/HSL validators and token prefix rules

2 participants