fix(template): guard optional property in nested test#113
fix(template): guard optional property in nested test#113OmarElzero wants to merge 1 commit intoaccordproject:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the optional-nested “good” template to satisfy the stricter optional-property type checking introduced in PR #53 by guarding access to the optional age field, and refreshes the interpreter snapshot accordingly.
Changes:
- Wrap
ageusage intest/templates/good/optional-nested/template.mdwith an{{#optional}}guard. - Update the Jest snapshot to reflect the generated
Optionalnode output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
test/templates/good/optional-nested/template.md |
Adds an {{#optional age}} guard around the age interpolation in the template. |
test/__snapshots__/TemplateMarkInterpreter.test.ts.snap |
Updates expected generated AgreementMark/CiceroMark JSON (including Optional node structure and list tightness). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| - You are *{{age}}* years old | ||
| - You are *{{#optional age}}{{this}}{{/optional}}* years old | ||
|
|
There was a problem hiding this comment.
The blank line between list items (after the age bullet) changes the CommonMark list from tight to loose (snapshot tight flips to false). Since this PR’s goal is only to add an optional guard, consider removing the blank line to preserve the original list structure/output and avoid an unrelated snapshot change.
| {{/clause}} | ||
|
|
||
| - You are *{{age}}* years old | ||
| - You are *{{#optional age}}{{this}}{{/optional}}* years old |
There was a problem hiding this comment.
Wrapping only {{age}} means that when age is absent the template will still emit the bullet - You are ** years old (empty emphasis/content). To make the optional handling render cleanly, wrap the whole list item in the {{#optional age}}...{{/optional}} block or provide an {{else}} branch with fallback text.
| - You are *{{#optional age}}{{this}}{{/optional}}* years old | |
| {{#optional age}}- You are *{{this}}* years old{{/optional}} |
The optional-nested test was failing after stricter optional property checks were added. This change wraps the 'age' variable in the template with an optional guard to align with the model. Fixes accordproject#112 Signed-off-by: OmarElzero <omarmohmed7659944@gmail.com>
bd7453d to
2005b0d
Compare
This pull request resolves a test failure in
test/TemplateMarkInterpreter.test.tsthat occurred after the stricter optional property checks were introduced in PR #53.The
should generate optional-nestedtest was failing with the errorOptional properties used without guards: age. This was because the template was using an optional property (age) without a guard.This fix wraps the
agevariable in thetest/templates/good/optional-nested/template.mdfile with an{{#optional}}block, ensuring it conforms to the new validation rules. The corresponding test snapshot has also been updated.Fixes #112