Skip to content

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haribshahbaz committed Oct 25, 2023
1 parent f5dd93a commit af908f4
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('Module: DeprecatedGlobalAppBlockType', () => {

it('does not reject global string used outside liquid control flow statements', async () => {
const sourceCode = `
{{ "@global" }}
<p> This is "@global" </p>
<script> var i = "@global" </script>
{% schema %}
Expand Down Expand Up @@ -119,4 +120,21 @@ describe('Module: DeprecatedGlobalAppBlockType', () => {

expect(highlights).toHaveLength(0);
});

it('rejects global string used in liquid control flow statements', async () => {
const sourceCode = `
{% if var = "@global" %}
<p> This is "@global" </p>
{% endif %}
`;

const offenses = await runLiquidCheck(DeprecatedGlobalAppBlockType, sourceCode);
expect(offenses).toHaveLength(1);
expect(offenses[0].message).toEqual(
'The global app block type `@global` is deprecated. Use `@app` instead.',
);

const highlights = highlightedOffenses({ 'file.liquid': sourceCode }, offenses);
expect(highlights).toEqual([`{% if var = "@global" %}`]);
});
});

0 comments on commit af908f4

Please sign in to comment.