From 2005b0d2e533d619894c275824db314608fc0b70 Mon Sep 17 00:00:00 2001 From: OmarElzero Date: Sat, 21 Mar 2026 08:43:46 +0200 Subject: [PATCH] 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 --- .../TemplateMarkInterpreter.test.ts.snap | 45 ++++++++++--------- .../good/optional-nested/template.md | 2 +- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/test/__snapshots__/TemplateMarkInterpreter.test.ts.snap b/test/__snapshots__/TemplateMarkInterpreter.test.ts.snap index a8ae360..52c7803 100644 --- a/test/__snapshots__/TemplateMarkInterpreter.test.ts.snap +++ b/test/__snapshots__/TemplateMarkInterpreter.test.ts.snap @@ -3506,37 +3506,42 @@ exports[`templatemark interpreter should generate optional-nested 1`] = ` ], }, { - "$class": "org.accordproject.commonmark@0.5.0.List", + "$class": "org.accordproject.commonmark@0.5.0.Paragraph", "nodes": [ { - "$class": "org.accordproject.commonmark@0.5.0.Item", + "$class": "org.accordproject.ciceromark@0.6.0.Optional", + "elementType": "Integer", + "hasSome": true, + "name": "age", "nodes": [ { - "$class": "org.accordproject.commonmark@0.5.0.Paragraph", + "$class": "org.accordproject.commonmark@0.5.0.Text", + "text": "- You are ", + }, + { + "$class": "org.accordproject.commonmark@0.5.0.Emph", "nodes": [ { - "$class": "org.accordproject.commonmark@0.5.0.Text", - "text": "You are ", - }, - { - "$class": "org.accordproject.commonmark@0.5.0.Emph", - "nodes": [ - { - "$class": "org.accordproject.ciceromark@0.6.0.Variable", - "elementType": "Integer", - "name": "age", - "value": "42", - }, - ], - }, - { - "$class": "org.accordproject.commonmark@0.5.0.Text", - "text": " years old", + "$class": "org.accordproject.ciceromark@0.6.0.Variable", + "elementType": "Integer", + "name": "this", + "value": "42", }, ], }, + { + "$class": "org.accordproject.commonmark@0.5.0.Text", + "text": " years old", + }, ], + "whenNone": [], + "whenSome": [], }, + ], + }, + { + "$class": "org.accordproject.commonmark@0.5.0.List", + "nodes": [ { "$class": "org.accordproject.commonmark@0.5.0.Item", "nodes": [ diff --git a/test/templates/good/optional-nested/template.md b/test/templates/good/optional-nested/template.md index b0e83d6..a5fd4ea 100644 --- a/test/templates/good/optional-nested/template.md +++ b/test/templates/good/optional-nested/template.md @@ -36,7 +36,7 @@ {{country}} {{/clause}} -- You are *{{age}}* years old +{{#optional age}}- You are *{{this}}* years old{{/optional}} - Your monthly salary is {{salary as "0,0.00 CCC"}} - Your favorite colours are {{#join favoriteColors}}