Skip to content

Commit bdfdee9

Browse files
committed
Add stage-2 ast tests for doc tags
1 parent 4f52a90 commit bdfdee9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/liquid-html-parser/src/stage-2-ast.spec.ts

+22
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,28 @@ describe('Unit: Stage 2 (AST)', () => {
12201220
expectPath(ast, 'children.0.markup.1.children.0.children.1.markup.name').to.eql('var3');
12211221
});
12221222

1223+
it(`should parse doc tags`, () => {
1224+
ast = toLiquidAST(`{% doc %}{% enddoc %}`);
1225+
expectPath(ast, 'children.0.type').to.eql('LiquidRawTag');
1226+
expectPath(ast, 'children.0.name').to.eql('doc');
1227+
expectPath(ast, 'children.0.body.value').to.eql('');
1228+
1229+
ast = toLiquidAST(`{% doc -%} single line doc {%- enddoc %}`);
1230+
expectPath(ast, 'children.0.type').to.eql('LiquidRawTag');
1231+
expectPath(ast, 'children.0.name').to.eql('doc');
1232+
expectPath(ast, 'children.0.body.value').to.eql(' single line doc ');
1233+
1234+
ast = toLiquidAST(`{% doc -%}
1235+
multi line doc
1236+
multi line doc
1237+
{%- enddoc %}`);
1238+
expectPath(ast, 'children.0.type').to.eql('LiquidRawTag');
1239+
expectPath(ast, 'children.0.name').to.eql('doc');
1240+
expectPath(ast, 'children.0.body.source').to.eql(
1241+
'{% doc -%}\n multi line doc\n multi line doc\n {%- enddoc %}',
1242+
);
1243+
});
1244+
12231245
it('should parse unclosed tables with assignments', () => {
12241246
ast = toLiquidAST(`
12251247
{%- liquid

0 commit comments

Comments
 (0)