Skip to content

Commit

Permalink
test: add tests to language service
Browse files Browse the repository at this point in the history
  • Loading branch information
tscpp committed Jun 27, 2024
1 parent e5417ca commit b98bb4c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- ok with: default from "./hover.viewmodel" -->
<p data-bind="text: hello"></p>
<!-- /ok -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class {
hello = "hello";
}
41 changes: 41 additions & 0 deletions packages/language-service/src/features/hover.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { LanguageService } from "../index.js";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";

describe("hover", () => {
let service: LanguageService;
let fileName: string;

beforeAll(async () => {
service = new LanguageService({
worker: false,
});
fileName = fileURLToPath(
new URL("__fixtures__/hover.html", import.meta.url),
);
const text = await readFile(fileName, "utf8");
await service.openDocument(fileName, text);
});

it("provides hover details for bindings (name)", async () => {
const hover = await service.getHover({
fileName: fileName,
position: {
line: 1,
column: 17,
},
});
expect(hover).not.toBe(null);
});

it("provides hover details for viewmodel property", async () => {
const hover = await service.getHover({
fileName: fileName,
position: {
line: 1,
column: 23,
},
});
expect(hover).not.toBe(null);
});
});
4 changes: 2 additions & 2 deletions packages/language-service/tsconfig.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/language-service/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": ["@tools/tsconfig/node.json"],
"include": ["src"]
"include": ["src"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "**/__fixtures__"]
}

0 comments on commit b98bb4c

Please sign in to comment.