-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Somehow this fell through the cracks. E2E tests only use the default settings, and tests at the lower levels didn't catch the missing link in the server.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/language-services/src/features/__tests__/do-complete-node-modules.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { test, assert, beforeEach } from "vitest"; | ||
import { getLanguageService } from "../../language-services"; | ||
import { Position } from "../../language-services-types"; | ||
import { getOptions } from "../../utils/test-helpers"; | ||
|
||
const { fileSystemProvider, ...rest } = getOptions(); | ||
const ls = getLanguageService({ fileSystemProvider, ...rest }); | ||
|
||
beforeEach(() => { | ||
ls.clearCache(); | ||
ls.configure({ | ||
completionSettings: { | ||
suggestFromUseOnly: true, | ||
}, | ||
}); // Reset any configuration to default | ||
}); | ||
|
||
test("symbols forwarded from node_modules don't get suggested unless used", async () => { | ||
const pkg = fileSystemProvider.createDocument(['{ "name": "test-module" }'], { | ||
Check warning on line 19 in packages/language-services/src/features/__tests__/do-complete-node-modules.test.ts GitHub Actions / test (ubuntu-latest)
Check warning on line 19 in packages/language-services/src/features/__tests__/do-complete-node-modules.test.ts GitHub Actions / test (macos-13)
|
||
languageId: "json", | ||
uri: "node_modules/sass-true/package.json", | ||
}); | ||
const module = fileSystemProvider.createDocument( | ||
["$catch-errors: false !default;"], | ||
{ | ||
uri: "node_modules/sass-true/_throw.scss", | ||
}, | ||
); | ||
const forward = fileSystemProvider.createDocument(['@forward "sass-true";'], { | ||
uri: "_test.scss", | ||
}); | ||
const unrelated = fileSystemProvider.createDocument(["@debug $"]); | ||
|
||
ls.parseStylesheet(module); | ||
ls.parseStylesheet(forward); | ||
ls.parseStylesheet(unrelated); | ||
|
||
const { items } = await ls.doComplete(unrelated, Position.create(0, 8)); | ||
assert.notOk( | ||
items.find((item) => item.label === "$catch-errors"), | ||
"Expected not to find $catch-errors in suggestions", | ||
); | ||
}); |