@@ -1231,7 +1231,8 @@ describe('Unit: Stage 2 (AST)', () => {
1231
1231
1232
1232
ast = toLiquidAST ( `
1233
1233
{% doc -%}
1234
- @param asdf
1234
+ @param requiredParameter
1235
+ @param [optionalParameter] - optional parameter description
1235
1236
@param {String} paramWithDescription - param with description and \`punctation\`. This is still a valid param description.
1236
1237
@unsupported this node falls back to a text node
1237
1238
{%- enddoc %}
@@ -1240,22 +1241,36 @@ describe('Unit: Stage 2 (AST)', () => {
1240
1241
expectPath ( ast , 'children.0.name' ) . to . eql ( 'doc' ) ;
1241
1242
expectPath ( ast , 'children.0.body.nodes.0.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1242
1243
expectPath ( ast , 'children.0.body.nodes.0.name' ) . to . eql ( 'param' ) ;
1244
+ expectPath ( ast , 'children.0.body.nodes.0.required' ) . to . eql ( true ) ;
1243
1245
expectPath ( ast , 'children.0.body.nodes.0.paramName.type' ) . to . eql ( 'TextNode' ) ;
1244
- expectPath ( ast , 'children.0.body.nodes.0.paramName.value' ) . to . eql ( 'asdf ' ) ;
1246
+ expectPath ( ast , 'children.0.body.nodes.0.paramName.value' ) . to . eql ( 'requiredParameter ' ) ;
1245
1247
expectPath ( ast , 'children.0.body.nodes.0.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1246
1248
expectPath ( ast , 'children.0.body.nodes.0.paramDescription.value' ) . to . eql ( '' ) ;
1249
+
1247
1250
expectPath ( ast , 'children.0.body.nodes.1.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1248
1251
expectPath ( ast , 'children.0.body.nodes.1.name' ) . to . eql ( 'param' ) ;
1252
+ expectPath ( ast , 'children.0.body.nodes.1.required' ) . to . eql ( false ) ;
1249
1253
expectPath ( ast , 'children.0.body.nodes.1.paramName.type' ) . to . eql ( 'TextNode' ) ;
1250
- expectPath ( ast , 'children.0.body.nodes.1.paramName.value' ) . to . eql ( 'paramWithDescription ' ) ;
1254
+ expectPath ( ast , 'children.0.body.nodes.1.paramName.value' ) . to . eql ( 'optionalParameter ' ) ;
1251
1255
expectPath ( ast , 'children.0.body.nodes.1.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1252
1256
expectPath ( ast , 'children.0.body.nodes.1.paramDescription.value' ) . to . eql (
1257
+ 'optional parameter description' ,
1258
+ ) ;
1259
+
1260
+ expectPath ( ast , 'children.0.body.nodes.2.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1261
+ expectPath ( ast , 'children.0.body.nodes.2.name' ) . to . eql ( 'param' ) ;
1262
+ expectPath ( ast , 'children.0.body.nodes.2.required' ) . to . eql ( true ) ;
1263
+ expectPath ( ast , 'children.0.body.nodes.2.paramName.type' ) . to . eql ( 'TextNode' ) ;
1264
+ expectPath ( ast , 'children.0.body.nodes.2.paramName.value' ) . to . eql ( 'paramWithDescription' ) ;
1265
+ expectPath ( ast , 'children.0.body.nodes.2.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1266
+ expectPath ( ast , 'children.0.body.nodes.2.paramDescription.value' ) . to . eql (
1253
1267
'param with description and `punctation`. This is still a valid param description.' ,
1254
1268
) ;
1255
- expectPath ( ast , 'children.0.body.nodes.1.paramType.type' ) . to . eql ( 'TextNode' ) ;
1256
- expectPath ( ast , 'children.0.body.nodes.1.paramType.value' ) . to . eql ( 'String' ) ;
1257
- expectPath ( ast , 'children.0.body.nodes.2.type' ) . to . eql ( 'TextNode' ) ;
1258
- expectPath ( ast , 'children.0.body.nodes.2.value' ) . to . eql (
1269
+ expectPath ( ast , 'children.0.body.nodes.2.paramType.type' ) . to . eql ( 'TextNode' ) ;
1270
+ expectPath ( ast , 'children.0.body.nodes.2.paramType.value' ) . to . eql ( 'String' ) ;
1271
+
1272
+ expectPath ( ast , 'children.0.body.nodes.3.type' ) . to . eql ( 'TextNode' ) ;
1273
+ expectPath ( ast , 'children.0.body.nodes.3.value' ) . to . eql (
1259
1274
'@unsupported this node falls back to a text node' ,
1260
1275
) ;
1261
1276
} ) ;
0 commit comments