@@ -14,7 +14,7 @@ describe('Module: UnsupportedDocTag', () => {
1414
1515 expect ( offenses ) . to . have . length ( 1 ) ;
1616 expect ( offenses [ 0 ] . message ) . to . equal (
17- 'The `doc` tag can only be used within a snippet or block. ' ,
17+ 'The `doc` must be placed directly within an inline snippet tag, not nested inside other tags ' ,
1818 ) ;
1919 } ) ;
2020
@@ -42,4 +42,39 @@ describe('Module: UnsupportedDocTag', () => {
4242
4343 expect ( offenses ) . to . be . empty ;
4444 } ) ;
45+
46+ it ( 'should not report an error when `doc` tag is used inside inline snippet' , async ( ) => {
47+ const layoutSourceCode = `
48+ {% snippet %}
49+ ${ sourceCode }
50+ {% endsnippet %}
51+ ` ;
52+
53+ const offenses = await runLiquidCheck (
54+ UnsupportedDocTag ,
55+ layoutSourceCode ,
56+ 'file://layout/theme.liquid' ,
57+ ) ;
58+
59+ expect ( offenses ) . to . be . empty ;
60+ } ) ;
61+
62+ it ( 'should report an error when `doc` tag is nested inside a block within a snippet file' , async ( ) => {
63+ const nestedSourceCode = `
64+ {% if true %}
65+ ${ sourceCode }
66+ {% endif %}
67+ ` ;
68+
69+ const offenses = await runLiquidCheck (
70+ UnsupportedDocTag ,
71+ nestedSourceCode ,
72+ 'file://snippets/file.liquid' ,
73+ ) ;
74+
75+ expect ( offenses ) . to . have . length ( 1 ) ;
76+ expect ( offenses [ 0 ] . message ) . to . equal (
77+ 'The `doc` tag must be a top-level tag within a snippet/block file' ,
78+ ) ;
79+ } ) ;
4580} ) ;
0 commit comments