Skip to content

Commit bd7453d

Browse files
committed
fix(template): guard optional property in nested test
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 #112 Signed-off-by: OmarElzero <omarmohmed7659944@gmail.com>
1 parent d25a21a commit bd7453d

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

test/__snapshots__/TemplateMarkInterpreter.test.ts.snap

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,10 +3522,20 @@ exports[`templatemark interpreter should generate optional-nested 1`] = `
35223522
"$class": "org.accordproject.commonmark@0.5.0.Emph",
35233523
"nodes": [
35243524
{
3525-
"$class": "org.accordproject.ciceromark@0.6.0.Variable",
3525+
"$class": "org.accordproject.ciceromark@0.6.0.Optional",
35263526
"elementType": "Integer",
3527+
"hasSome": true,
35273528
"name": "age",
3528-
"value": "42",
3529+
"nodes": [
3530+
{
3531+
"$class": "org.accordproject.ciceromark@0.6.0.Variable",
3532+
"elementType": "Integer",
3533+
"name": "this",
3534+
"value": "42",
3535+
},
3536+
],
3537+
"whenNone": [],
3538+
"whenSome": [],
35293539
},
35303540
],
35313541
},
@@ -3577,7 +3587,7 @@ exports[`templatemark interpreter should generate optional-nested 1`] = `
35773587
],
35783588
},
35793589
],
3580-
"tight": "true",
3590+
"tight": "false",
35813591
"type": "bullet",
35823592
},
35833593
{

test/templates/good/optional-nested/template.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
{{country}}
3737
{{/clause}}
3838

39-
- You are *{{age}}* years old
39+
- You are *{{#optional age}}{{this}}{{/optional}}* years old
40+
4041
- Your monthly salary is {{salary as "0,0.00 CCC"}}
4142
- Your favorite colours are {{#join favoriteColors}}
4243

0 commit comments

Comments
 (0)