import { afterEach, describe, expect, it } from "vitest"; import { EditorState } from "@codemirror/state"; import { EditorView } from "@codemirror/view"; import { HIGHLIGHTING_LEVEL_ITEMS, highlightingLevelField, highlightingLevelOf, setHighlightingLevel, } from "./localAppearance"; const views: EditorView[] = []; afterEach(() => views.splice(0).forEach((view) => view.destroy())); describe("highlightingLevelField", () => { it("starts at All Problems and switches through the three levels", () => { let state = EditorState.create({ doc: "const x = 1;", extensions: [highlightingLevelField] }); expect(highlightingLevelOf(state)).toBe("inspections"); for (const level of ["syntax", "none", "inspections"] as const) { state = state.update({ effects: setHighlightingLevel.of(level) }).state; expect(highlightingLevelOf(state)).toBe(level); } }); it("labels the three levels in IDEA's order and wording", () => { expect(HIGHLIGHTING_LEVEL_ITEMS.map((item) => item.label)).toEqual(["None", "Syntax", "All Problems"]); }); it("reports All Problems for a state without the field", () => { expect(highlightingLevelOf(EditorState.create({ doc: "x" }))).toBe("inspections"); }); });