mirror of
https://github.com/zadam/trilium.git
synced 2026-01-03 21:24:24 +01:00
feat(test): basic tests for ESLint
This commit is contained in:
parent
770b4afff3
commit
3756524ad3
29
src/public/app/services/eslint.spec.ts
Normal file
29
src/public/app/services/eslint.spec.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { lint } from "./eslint.js";
|
||||
import { trimIndentation } from "../../../../spec/support/utils.js";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("Linter", () => {
|
||||
it("reports some basic errors", async () => {
|
||||
const result = await lint(trimIndentation`
|
||||
for (const i = 0; i<10; i++) {
|
||||
}
|
||||
`);
|
||||
expect(result).toMatchObject([
|
||||
{ message: "'i' is constant.", },
|
||||
{ message: "Empty block statement." }
|
||||
]);
|
||||
});
|
||||
|
||||
it("reports no error for correct script", async () => {
|
||||
const result = await lint(trimIndentation`
|
||||
const foo = "bar";
|
||||
console.log(foo.toString());
|
||||
for (const x of [ 1, 2, 3]) {
|
||||
console.log(x?.toString());
|
||||
}
|
||||
|
||||
api.showMessage("Hi");
|
||||
`);
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user