test(renderer): Canvas Candy cssclasses enrichment conformance (#16, slice 2) - #68
Merged
Merged
Conversation
…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>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second slice of #16 — conformance for the Canvas Candy
cssclassesenrichment layer. 35 tests incssclasses.test.ts. Pure-TS (js-yamlonly, nounified/remark), runs under the existing ts-jest config with no mocking.Coverage:
hasCssClassesfast-path — frontmatter detection,cssclass(es)alias, plain & non-text nodes (zero-overhead path), any-match-in-listnullwhen no frontmatter or no cssclasses keydisplayText— block + leading newlines stripped, body preserved verbatimrounded=pill + dropshadow + additive selective sides; text-align; parametric regexes (gradient°, rotate-card, rotate-text incl. trailingl); unknown-class silent ignoreenrichNodesbatch — text enriched, others pass through by referenceFinding (documented in tests)
js-yaml's
FAILSAFE_SCHEMAloads every scalar as a string, socssclasses: 42becomes the class"42"(enriched, maps to no props) rather than a rejected number. Only non-scalar values (nested mappings) yieldnull. The tests assert the actual behaviour — caught my own wrong assumption mid-write.Scope
parseCallouts: pulls in the unified/remark ESM chain; belongs with a one-time jest-ESM solution, not per-test mocking.Test plan
Part of #16.
🤖 Generated with Claude Code