@@ -1316,6 +1316,70 @@ describe('Unit: Stage 1 (CST)', () => {
1316
1316
expectPath ( cst , '0.children.1.type' ) . to . equal ( 'LiquidDocExampleNode' ) ;
1317
1317
expectPath ( cst , '0.children.1.exampleContent.value' ) . to . equal ( 'second example\n' ) ;
1318
1318
} ) ;
1319
+
1320
+ it ( 'should parse @description node' , ( ) => {
1321
+ const testStr = `{% doc %} @description {%- enddoc %}` ;
1322
+ cst = toCST ( testStr ) ;
1323
+ expectPath ( cst , '0.type' ) . to . equal ( 'LiquidRawTag' ) ;
1324
+ expectPath ( cst , '0.name' ) . to . equal ( 'doc' ) ;
1325
+ expectPath ( cst , '0.children.0.type' ) . to . equal ( 'LiquidDocDescriptionNode' ) ;
1326
+ expectPath ( cst , '0.children.0.content.value' ) . to . equal ( '' ) ;
1327
+ } ) ;
1328
+
1329
+ it ( 'should parse @description node' , ( ) => {
1330
+ const testStr = `{% doc %}
1331
+ @description This is a description
1332
+ @description This is a second description
1333
+ {% enddoc %}` ;
1334
+ cst = toCST ( testStr ) ;
1335
+ expectPath ( cst , '0.children.0.type' ) . to . equal ( 'LiquidDocDescriptionNode' ) ;
1336
+ expectPath ( cst , '0.children.0.content.value' ) . to . equal ( 'This is a description\n' ) ;
1337
+
1338
+ expectPath ( cst , '0.children.1.type' ) . to . equal ( 'LiquidDocDescriptionNode' ) ;
1339
+ expectPath ( cst , '0.children.1.content.value' ) . to . equal ( 'This is a second description\n' ) ;
1340
+ } ) ;
1341
+
1342
+ it ( 'should parse and strip whitespace from description tag with content that has leading whitespace' , ( ) => {
1343
+ const testStr = `{% doc %} @description hello there {%- enddoc %}` ;
1344
+ cst = toCST ( testStr ) ;
1345
+ expectPath ( cst , '0.type' ) . to . equal ( 'LiquidRawTag' ) ;
1346
+ expectPath ( cst , '0.name' ) . to . equal ( 'doc' ) ;
1347
+ expectPath ( cst , '0.children.0.type' ) . to . equal ( 'LiquidDocDescriptionNode' ) ;
1348
+ expectPath ( cst , '0.children.0.name' ) . to . equal ( 'description' ) ;
1349
+ expectPath ( cst , '0.children.0.content.value' ) . to . equal ( 'hello there' ) ;
1350
+ expectPath ( cst , '0.children.0.content.locStart' ) . to . equal ( testStr . indexOf ( 'hello there' ) ) ;
1351
+ expectPath ( cst , '0.children.0.content.locEnd' ) . to . equal (
1352
+ testStr . indexOf ( 'hello there' ) + 'hello there' . length ,
1353
+ ) ;
1354
+ } ) ;
1355
+
1356
+ it ( 'should parse description node with whitespace and new lines' , ( ) => {
1357
+ const testStr = `{% doc %}
1358
+ @description hello there my friend
1359
+ This is a description
1360
+ It supports multiple lines
1361
+ {% enddoc %}` ;
1362
+ cst = toCST ( testStr ) ;
1363
+ expectPath ( cst , '0.type' ) . to . equal ( 'LiquidRawTag' ) ;
1364
+ expectPath ( cst , '0.name' ) . to . equal ( 'doc' ) ;
1365
+ expectPath ( cst , '0.children.0.type' ) . to . equal ( 'LiquidDocDescriptionNode' ) ;
1366
+ expectPath ( cst , '0.children.0.name' ) . to . equal ( 'description' ) ;
1367
+ expectPath ( cst , '0.children.0.content.value' ) . to . equal (
1368
+ 'hello there my friend\n This is a description\n It supports multiple lines\n' ,
1369
+ ) ;
1370
+ } ) ;
1371
+
1372
+ it ( 'should parse multiple description nodes' , ( ) => {
1373
+ const testStr = `{% doc %}
1374
+ @description hello there
1375
+ @description second description
1376
+ {% enddoc %}` ;
1377
+ cst = toCST ( testStr ) ;
1378
+ expectPath ( cst , '0.children.0.type' ) . to . equal ( 'LiquidDocDescriptionNode' ) ;
1379
+ expectPath ( cst , '0.children.0.content.value' ) . to . equal ( 'hello there\n' ) ;
1380
+ expectPath ( cst , '0.children.1.type' ) . to . equal ( 'LiquidDocDescriptionNode' ) ;
1381
+ expectPath ( cst , '0.children.1.content.value' ) . to . equal ( 'second description\n' ) ;
1382
+ } ) ;
1319
1383
}
1320
1384
} ) ;
1321
1385
} ) ;
0 commit comments