Skip to content

Commit

Permalink
Windows shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
charlespwd committed Nov 26, 2024
1 parent 6c85be1 commit 1965666
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions packages/theme/src/cli/services/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => ({
Expand Down Expand Up @@ -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},
Expand All @@ -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},
Expand All @@ -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},
Expand All @@ -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},
Expand All @@ -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]],
})
})
})
Expand Down

0 comments on commit 1965666

Please sign in to comment.