Overview
template-sync currently has no unit tests. The key functions to test are:
generateNewContent — core output generation
getTypeVariants — schema parsing into variant map
mergeAllOfProperties / withEnumPlaceholders / commentedHint — helpers (test via generateNewContent where possible)
Test cases
generateNewContent
- Produces correct frontmatter structure (header comment, required fields, optional commented hints) for a known variant (e.g.
opportunity from general.json)
fieldMap remapping: canonical keys in the schema (status) are remapped to file keys (record_status) in the output YAML, and property descriptions still attach to the correct line
- Inverse fieldMap: a round-trip check that
invertFieldMap followed by generateNewContent produces file-field keys, not canonical keys
- Enum fields are expanded to
val1|val2|... placeholder format
- Integer fields with min/max use midpoint as placeholder
- Optional fields not in the example appear as
# field: ... comment hints
- Body is preserved verbatim after the closing
---
getTypeVariants
- Returns expected set of type names from
general.json
- Skips
dashboard and ost_on_a_page variants
- Skips variants with no
examples[0]
Notes
- Use
general.json (from schemas/) as the schema source — no need for additional fixtures
- Plain objects are fine for mock variants where full schema resolution isn't needed
- Do not mock filesystem — test the functions directly with imported schema data
- Avoid testing
templateSync (the async orchestrator) as it couples to the filesystem and console output; the unit-testable logic is in the helpers
Overview
template-synccurrently has no unit tests. The key functions to test are:generateNewContent— core output generationgetTypeVariants— schema parsing into variant mapmergeAllOfProperties/withEnumPlaceholders/commentedHint— helpers (test viagenerateNewContentwhere possible)Test cases
generateNewContentopportunityfromgeneral.json)fieldMapremapping: canonical keys in the schema (status) are remapped to file keys (record_status) in the output YAML, and property descriptions still attach to the correct lineinvertFieldMapfollowed bygenerateNewContentproduces file-field keys, not canonical keysval1|val2|...placeholder format# field: ...comment hints---getTypeVariantsgeneral.jsondashboardandost_on_a_pagevariantsexamples[0]Notes
general.json(fromschemas/) as the schema source — no need for additional fixturestemplateSync(the async orchestrator) as it couples to the filesystem and console output; the unit-testable logic is in the helpers