Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Feb 14, 2024
1 parent 016767d commit a997034
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
4 changes: 1 addition & 3 deletions server/src/browserServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
DidChangeConfigurationNotification
} from "vscode-languageserver/browser";

let startupReady = false;

/* browser specific setup code */
const messageReader = new BrowserMessageReader(self);
Expand Down Expand Up @@ -105,7 +104,6 @@ connection.onNotification("update-meta-store", async e => {
// documents.all().forEach(v => validate(v, v.getText(), v.version));
}
catch { /**/ }
startupReady = true;
});

connection.onNotification("watch-dotrain", async e => {
Expand Down Expand Up @@ -261,7 +259,7 @@ async function getSetting() {

// validate a document
async function validate(uri: string, text: string, version: number, languageId: string) {
if (startupReady && languageId === "rainlang") {
if (languageId === "rainlang") {
langServices.doValidateAsync({ uri, text, version, languageId }, true).then(
diagnostics => {
if (version === documents.get(uri)?.version) {
Expand Down
7 changes: 2 additions & 5 deletions server/src/nodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import {
DidChangeConfigurationNotification
} from "vscode-languageserver/node";

let startupReady = false;

// Create a connection for the server, using Node's IPC as a transport.
// Also include all preview / proposed LSP features.
const connection = createConnection(ProposedFeatures.all);
Expand Down Expand Up @@ -102,7 +100,6 @@ connection.onNotification("update-meta-store", async e => {
// documents.all().forEach(v => validate(v, v.getText(), v.version));
}
catch { /**/ }
startupReady = true;
});

connection.onNotification("watch-dotrain", async e => {
Expand Down Expand Up @@ -263,11 +260,11 @@ async function getSetting() {

// validate a document
async function validate(uri: string, text: string, version: number, languageId: string) {
if (startupReady && languageId === "rainlang") {
if (languageId === "rainlang") {
langServices.doValidateAsync({ uri, text, version, languageId }, true).then(
diagnostics => {
if (version === documents.get(uri)?.version) {
connection.sendDiagnostics({ uri, diagnostics });
connection.sendDiagnostics({ uri, diagnostics });
}
},
() => { /**/ }
Expand Down
6 changes: 2 additions & 4 deletions test/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ async function testCompletion(
position
)) as vscode.CompletionList;

actualCompletionList.items = actualCompletionList.items.filter(
v => typeof v.label === "string" ? v.label.includes("add") : v.label.label.includes("add")
);
assert.ok(actualCompletionList.items.length == 2);
expectedCompletionList.items.forEach((expectedItem, i) => {
const actualItem = actualCompletionList.items[i];
Expand All @@ -37,7 +34,8 @@ suite("Rainlang Code Completion", () => {
test("Should provide filtered completion items based on provided position", async () => {
await testCompletion(docUri, new vscode.Position(3, 6), {
items: [
{ label: "literal", kind: vscode.CompletionItemKind.Constant },
{ label: "expression", kind: vscode.CompletionItemKind.Class },
{ label: "literal", kind: vscode.CompletionItemKind.Class },
]
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ suite("Rainlang Diagnostics", () => {
test("Should detect diagnostics correctly", async () => {
await testDiagnostics(docUri, [
{
message : "Expected Semi",
message : "expected semi",
range : toRange(2, 16, 2, 16),
severity: vscode.DiagnosticSeverity.Error,
code : 1032,
Expand Down

0 comments on commit a997034

Please sign in to comment.