Skip to content

Commit 133dd36

Browse files
committed
Fix tests on Windows
1 parent a9f5954 commit 133dd36

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/tailwindcss-language-server/src/project-locator.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { URL, fileURLToPath } from 'url'
55
import { Settings } from '@tailwindcss/language-service/src/util/state'
66
import { createResolver } from './resolver'
77
import { css, defineTest, js, json, scss, Storage, TestUtils } from './testing'
8+
import { normalizePath } from './utils'
89

910
let settings: Settings = {
1011
tailwindCSS: {
@@ -29,12 +30,14 @@ function testFixture(fixture: string, details: any[]) {
2930

3031
let detail = details[i]
3132

32-
let configPath = path.relative(fixturePath, project.config.path)
33+
let configPath = path.relative(normalizePath(fixturePath), project.config.path)
3334

3435
expect(configPath).toEqual(detail?.config)
3536

3637
if (detail?.content) {
37-
let expected = detail?.content.map((path) => path.replace('{URL}', fixturePath)).sort()
38+
let expected = detail?.content
39+
.map((path) => path.replace('{URL}', normalizePath(fixturePath)))
40+
.sort()
3841

3942
let actual = project.documentSelector
4043
.filter((selector) => selector.priority === 1 /** content */)
@@ -45,7 +48,9 @@ function testFixture(fixture: string, details: any[]) {
4548
}
4649

4750
if (detail?.selectors) {
48-
let expected = detail?.selectors.map((path) => path.replace('{URL}', fixturePath)).sort()
51+
let expected = detail?.selectors
52+
.map((path) => path.replace('{URL}', normalizePath(fixturePath)))
53+
.sort()
4954

5055
let actual = project.documentSelector.map((selector) => selector.pattern).sort()
5156

@@ -364,7 +369,7 @@ async function prepare({ root }: TestUtils) {
364369
} as Settings
365370

366371
function adjustPath(filepath: string) {
367-
filepath = filepath.replace(root, '{URL}')
372+
filepath = filepath.replace(normalizePath(root), '{URL}')
368373

369374
if (filepath.startsWith('{URL}/')) {
370375
filepath = filepath.slice(5)

0 commit comments

Comments
 (0)