From ecb341cf367a1002a32c0980f4aab40a9dfc4280 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Tue, 26 Nov 2024 10:20:17 -0500 Subject: [PATCH] Windows shenanigans --- packages/theme/src/cli/services/check.test.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/theme/src/cli/services/check.test.ts b/packages/theme/src/cli/services/check.test.ts index b5dad9cf7d..74a460aa24 100644 --- a/packages/theme/src/cli/services/check.test.ts +++ b/packages/theme/src/cli/services/check.test.ts @@ -10,7 +10,14 @@ import { import {fileExists, readFileSync, writeFile} from '@shopify/cli-kit/node/fs' import {outputInfo, outputSuccess} from '@shopify/cli-kit/node/output' import {renderInfo} from '@shopify/cli-kit/node/ui' -import {Severity, SourceCodeType, loadConfig, type Offense, type Theme} from '@shopify/theme-check-node' +import { + Severity, + SourceCodeType, + loadConfig, + path as pathUtils, + type Offense, + type Theme, +} from '@shopify/theme-check-node' import {Mock, MockInstance, afterAll, beforeEach, describe, expect, test, vi} from 'vitest' vi.mock('@shopify/cli-kit/node/fs', async () => ({ @@ -115,12 +122,14 @@ describe('formatOffenses', () => { describe('sortOffenses', () => { test('should sort offenses by file path', () => { + const uri1 = pathUtils.normalize('file:///path/to/file1') + const uri2 = pathUtils.normalize('file:///path/to/file2') const offenses: Offense[] = [ { type: SourceCodeType.LiquidHtml, check: 'LiquidHTMLSyntaxError', message: 'Attempting to close HtmlElement', - uri: 'file:///path/to/file2', + uri: uri2, severity: Severity.ERROR, start: {index: 0, line: 1, character: 0}, end: {index: 10, line: 1, character: 10}, @@ -129,7 +138,7 @@ describe('sortOffenses', () => { type: SourceCodeType.LiquidHtml, check: 'LiquidHTMLSyntaxError', message: 'Attempting to close HtmlElement', - uri: 'file:///path/to/file1', + uri: uri1, severity: Severity.WARNING, start: {index: 0, line: 1, character: 0}, end: {index: 10, line: 1, character: 10}, @@ -139,18 +148,19 @@ describe('sortOffenses', () => { const result = sortOffenses(offenses) expect(result).toEqual({ - '/path/to/file1': [offenses[1]], - '/path/to/file2': [offenses[0]], + [pathUtils.fsPath(uri1)]: [offenses[1]], + [pathUtils.fsPath(uri2)]: [offenses[0]], }) }) test('should sort offenses by severity within each file', () => { + const uri = pathUtils.normalize('file:///path/to/file') const offenses: Offense[] = [ { type: SourceCodeType.LiquidHtml, check: 'LiquidHTMLSyntaxError', message: 'Attempting to close HtmlElement', - uri: 'file:///path/to/file', + uri, severity: Severity.WARNING, start: {index: 0, line: 1, character: 0}, end: {index: 10, line: 1, character: 10}, @@ -159,7 +169,7 @@ describe('sortOffenses', () => { type: SourceCodeType.LiquidHtml, check: 'LiquidHTMLSyntaxError', message: 'Attempting to close HtmlElement', - uri: 'file:///path/to/file', + uri, severity: Severity.ERROR, start: {index: 0, line: 2, character: 0}, end: {index: 10, line: 2, character: 10}, @@ -169,7 +179,7 @@ describe('sortOffenses', () => { const result = sortOffenses(offenses) expect(result).toEqual({ - '/path/to/file': [offenses[1], offenses[0]], + [pathUtils.fsPath(uri)]: [offenses[1], offenses[0]], }) }) })