Skip to content

test(renderer): Canvas Candy cssclasses enrichment conformance (#16, slice 2) - #68

Merged
LeslieOA merged 1 commit into
developfrom
test/candy-cssclasses-conformance
Jun 3, 2026
Merged

test(renderer): Canvas Candy cssclasses enrichment conformance (#16, slice 2)#68
LeslieOA merged 1 commit into
developfrom
test/candy-cssclasses-conformance

Conversation

@LeslieOA

@LeslieOA LeslieOA commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

Second slice of #16 — conformance for the Canvas Candy cssclasses enrichment layer. 35 tests in cssclasses.test.ts. Pure-TS (js-yaml only, no unified/remark), runs under the existing ts-jest config with no mocking.

Coverage:

  • hasCssClasses fast-path — frontmatter detection, cssclass(es) alias, plain & non-text nodes (zero-overhead path), any-match-in-list
  • Frontmatter forms — array / comma-string / single-string / alias; trimming + empty drop; null when no frontmatter or no cssclasses key
  • displayText — block + leading newlines stripped, body preserved verbatim
  • Full class→renderProp map — shapes; fill/transparent/opaque/nocolor; border styles + rounded=pill + dropshadow + additive selective sides; text-align; parametric regexes (gradient°, rotate-card, rotate-text incl. trailing l); unknown-class silent ignore
  • Combinations + last-wins shape resolution
  • enrichNodes batch — text enriched, others pass through by reference

Finding (documented in tests)

js-yaml's FAILSAFE_SCHEMA loads every scalar as a string, so cssclasses: 42 becomes the class "42" (enriched, maps to no props) rather than a rejected number. Only non-scalar values (nested mappings) yield null. The tests assert the actual behaviour — caught my own wrong assumption mid-write.

Scope

Test plan

  • 116 tests pass (35 new), typecheck + lint clean
  • Pure logic — no device/native

Part of #16.

🤖 Generated with Claude Code

…slice 2)

Adds src/renderer/extensions/__tests__/cssclasses.test.ts (35 tests) covering
the cssclasses enrichment layer — pure-TS (js-yaml only, no unified/remark), so
it runs under the existing ts-jest config with no mocking.

Coverage:
  - hasCssClasses fast-path: detects frontmatter, cssclass(es) alias, plain &
    non-text nodes (zero-overhead path), any-match-in-list
  - frontmatter forms: array, comma-separated string, single string, alias;
    trimming + empty-entry drop; null when no frontmatter / no cssclasses key
  - displayText: frontmatter block + leading newlines stripped, body verbatim
  - full class→renderProp map: shapes, fill, borders (styles + rounded=pill +
    dropshadow + additive selective sides), text-align; parametric regexes
    (gradient deg, rotate-card, rotate-text incl. trailing `l`); unknown-class
    silent ignore
  - combinations + last-wins shape resolution
  - enrichNodes batch: text enriched, others pass through by reference

Documents a real FAILSAFE_SCHEMA quirk found while writing these: js-yaml's
FAILSAFE schema loads every scalar as a string, so `cssclasses: 42` becomes the
class "42" (enriched, maps to nothing) rather than a rejected number. Only
non-scalar values (nested mappings) yield null. Tests assert the actual
behaviour, not the assumed one.

Slice 3 (callouts parseCallouts) remains deferred — it pulls in the
unified/remark ESM chain that needs a one-time jest-ESM fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LeslieOA
LeslieOA merged commit 56b15bb into develop Jun 3, 2026
1 check passed
@LeslieOA
LeslieOA deleted the test/candy-cssclasses-conformance branch June 3, 2026 15:55
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