Skip to content

Commit

Permalink
Example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Feb 21, 2025
1 parent 14636a7 commit 71f2188
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/example.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nothing
bd spellin
43 changes: 43 additions & 0 deletions integration_tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,46 @@ test("should only highlight word in code", async () => {
}
});
});

test("should provide diagnostics for all example files", async () => {
const exampleDir = path.join(__dirname, "../examples");
const files = fs.readdirSync(exampleDir);

for (const file of files) {
const filePath = path.join(exampleDir, file);
const content = fs.readFileSync(filePath, "utf8");

await new Promise<void>((resolve, reject) => {
const timeoutId = setTimeout(() => {
reject(new Error(`Timeout waiting for diagnostics for ${file}`));
}, 5000);

try {
languageClient.once("textDocument/publishDiagnostics", (params) => {
try {
console.log(`Received diagnostics for ${file}:`, params);
expect(params).toBeDefined();
expect(params.diagnostics.length).toBeGreaterThan(0);
clearTimeout(timeoutId);
resolve();
} catch (error) {
clearTimeout(timeoutId);
reject(error);
}
});

languageClient.sendNotification("textDocument/didOpen", {
textDocument: {
uri: `file:///${file}`,
languageId: getLanguageFromFileName(file),
version: 1,
text: content,
},
});
} catch (error) {
clearTimeout(timeoutId);
reject(error);
}
});
}
});

0 comments on commit 71f2188

Please sign in to comment.