Skip to content

Commit

Permalink
test: confirm configuration is applied if given
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Dec 8, 2024
1 parent f0cc66d commit 93a9439
Showing 1 changed file with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { test, assert, beforeEach } from "vitest";
import {
defaultConfiguration,
getLanguageService,
} from "../../language-services";
import { DiagnosticSeverity } from "../../language-services-types";
import { getOptions } from "../../utils/test-helpers";

const { fileSystemProvider, ...rest } = getOptions();
const ls = getLanguageService({ fileSystemProvider, ...rest });

beforeEach(() => {
ls.clearCache();
ls.configure(defaultConfiguration);
});

test("reports an unknown at-rule", async () => {
const document = fileSystemProvider.createDocument(`
@tailwind base;
`);

const result = await ls.doDiagnostics(document);

assert.deepStrictEqual(result, [
{
code: "unknownAtRules",
message: "Unknown at rule @tailwind",
range: {
start: {
line: 1,
character: 0,
},
end: {
line: 1,
character: 9,
},
},
severity: DiagnosticSeverity.Warning,
source: "scss",
},
]);
});

test("ignores unknown at-rules if configured", async () => {
const document = fileSystemProvider.createDocument(`
@tailwind base;
`);

ls.configure({
...defaultConfiguration,
scss: {
...defaultConfiguration.scss,
diagnostics: {
...defaultConfiguration.scss.diagnostics,
lint: {
...defaultConfiguration.scss.diagnostics.lint,
unknownAtRules: "ignore",
},
},
},
});
const result = await ls.doDiagnostics(document);

assert.deepStrictEqual(result, []);
});

0 comments on commit 93a9439

Please sign in to comment.