Skip to content

Commit

Permalink
Fix the language server tests on Windows (#386)
Browse files Browse the repository at this point in the history
This replaces the use of `URL` with `vscode-uri`. This handles Windows
paths better than the combination of both.
  • Loading branch information
remcohaszing authored Jan 19, 2024
1 parent 433b87c commit 8e26d59
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 0 additions & 2 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
},
"devDependencies": {
"@types/node": "^20.0.0",
"@types/normalize-path": "^3.0.0",
"@volar/test-utils": "2.0.0-alpha.14",
"normalize-path": "^3.0.0",
"unified": "^11.0.0"
}
}
9 changes: 7 additions & 2 deletions packages/language-server/test/document-link.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ test('resolve markdown link references', async () => {
end: {line: 0, character: 12}
},
tooltip: 'Go to link definition',
target: fixtureUri('node16/link-reference.mdx?virtualCodeId=md#L3,8'),
target: fixtureUri(
'node16/link-reference.mdx?virtualCodeId=md#L3,8'
).replace('%3A', ':'),
data: {
uri: fixtureUri('node16/link-reference.mdx'),
original: {
Expand All @@ -43,7 +45,10 @@ test('resolve markdown link references', async () => {
pathText: 'mdx',
resource: {
$mid: 1,
path: fixturePath('node16/link-reference.mdx'),
path: fixturePath('node16/link-reference.mdx').replace(
/^\/?/,
'/'
),
query: 'virtualCodeId=md',
scheme: 'file'
},
Expand Down
6 changes: 2 additions & 4 deletions packages/language-server/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

import {createRequire} from 'node:module'
import path from 'node:path'
import {fileURLToPath} from 'node:url'
import {URI, Utils} from 'vscode-uri'
import {startLanguageServer} from '@volar/test-utils'
// eslint-disable-next-line import/order
import normalizePath from 'normalize-path'
import {startLanguageServer} from '@volar/test-utils'

const require = createRequire(import.meta.url)
const pkgPath = new URL('../package.json', import.meta.url)
Expand Down Expand Up @@ -45,5 +43,5 @@ export function fixtureUri(fileName) {
* @returns {string}
*/
export function fixturePath(fileName) {
return normalizePath(fileURLToPath(fixtureUri(fileName)))
return URI.parse(fixtureUri(fileName)).fsPath.replaceAll('\\', '/')
}

0 comments on commit 8e26d59

Please sign in to comment.