Skip to content

Commit 9366de6

Browse files
committed
Added more tests and added changeset
1 parent d281688 commit 9366de6

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

.changeset/hungry-ravens-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/theme-check-common': minor
3+
---
4+
5+
Introducing `doc` tags inside the new `snippet` tag, as well as making the theme check more rigorous with where the `doc` tag is placed

packages/theme-check-common/src/checks/unsupported-doc-tag/index.spec.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)