-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): Add e2e tests for language server
- Loading branch information
1 parent
2a95cc5
commit 147d868
Showing
21 changed files
with
769 additions
and
863 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use std::error::Error; | ||
|
||
/// TMP: log the response. | ||
pub fn handle_response(resp: lsp_server::Response) -> Result<(), Box<dyn Error + Sync + Send>> { | ||
eprintln!("handle_response: got {resp:?}"); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "language-server-tests", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^22.10.1", | ||
"vitest": "^2.1.8", | ||
"vscode-languageclient": "^9.0.1", | ||
"vscode-languageserver-protocol": "^3.17.5", | ||
"vscode-languageserver-textdocument": "^1.0.12", | ||
"vscode-uri": "^3.0.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("CSS - Colors", () => { | ||
it("should return something for a document colors request", async () => { | ||
const doc = await languageServer.openFakeDocument( | ||
`h1 { color: red; }`, | ||
"css" | ||
); | ||
|
||
const colors = await languageServer.sendDocumentColorRequest(doc.uri); | ||
|
||
expect(colors).toBeDefined(); | ||
|
||
const colorPresentations = | ||
await languageServer.sendColorPresentationRequest( | ||
doc.uri, | ||
colors[0].color, | ||
colors[0].range | ||
); | ||
|
||
expect(colorPresentations).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("CSS - Folding Ranges", () => { | ||
it("should return something for a folding ranges request", async () => { | ||
const doc = await languageServer.openFakeDocument( | ||
`h1 { color: red; }`, | ||
"css" | ||
); | ||
|
||
const foldingRanges = await languageServer.sendFoldingRangesRequest( | ||
doc.uri | ||
); | ||
|
||
expect(foldingRanges).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { Position } from "vscode-languageserver-protocol"; | ||
|
||
describe("CSS - Hover", () => { | ||
it("should return something for a hover request", async () => { | ||
const doc = await languageServer.openFakeDocument( | ||
`h1 { color: red; }`, | ||
"css" | ||
); | ||
|
||
const hover = await languageServer.sendHoverRequest( | ||
doc.uri, | ||
Position.create(0, 5) | ||
); | ||
|
||
expect(hover).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { ServerCapabilities } from "vscode-languageserver-protocol/node"; | ||
|
||
describe("Language server initilization", () => { | ||
it("Can init server", async () => { | ||
expect(languageServer).toBeDefined(); | ||
}); | ||
|
||
it("Has proper capabilities", async () => { | ||
const capabilities: ServerCapabilities = { | ||
colorProvider: true, | ||
foldingRangeProvider: true, | ||
hoverProvider: true, | ||
textDocumentSync: 1, | ||
}; | ||
|
||
expect(languageServer.initializeResult.capabilities).to.deep.equal( | ||
capabilities | ||
); | ||
}); | ||
}); |
Oops, something went wrong.