Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- ok with: default from "./diagnostics" -->
<p data-bind="text: helo"></p>
<!-- ko if: true -->
hello
<!-- /ko -->
<!-- /ok -->
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- ok with: default from "./hover.viewmodel" -->
<!-- ok with: default from "./hover" -->
<p data-bind="text: hello"></p>
<!-- /ok -->
3 changes: 3 additions & 0 deletions packages/language-service/src/features/__fixtures__/hover.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class {
hello = "hello";
}

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

38 changes: 38 additions & 0 deletions packages/language-service/src/features/diagnostics.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { type Diagnostics, LanguageService } from "../index.js";
import { describe, beforeAll, it, expect } from "@jest/globals";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";

describe("diagnostics", () => {
let diagnostics!: Diagnostics;

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

it("provides standard diagnostics", async () => {
const diagnostic = diagnostics.find(
(diagnostic) => diagnostic.code === "virtual-element-end-notation",
);
expect(diagnostic).not.toBe(undefined);
expect(diagnostic!.range.start.line).toBe(4);
});

it("provides typescript diagnostics", async () => {
const diagnostic = diagnostics.find(
(diagnostic) => diagnostic.code === "ts/2552",
);
expect(diagnostic).not.toBe(undefined);
expect(diagnostic!.range.start.line).toBe(1);
});
});