Skip to content

Commit 7c72d49

Browse files
committed
Add some tests
1 parent b5df1c5 commit 7c72d49

File tree

4 files changed

+51
-6
lines changed

4 files changed

+51
-6
lines changed

src/harness/client.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,16 @@ namespace ts.server {
196196
// Not passing along 'preferences' because server should already have those from the 'configure' command
197197
const args: protocol.CompletionsRequestArgs = this.createFileLocationRequestArgs(fileName, position);
198198

199-
const request = this.processRequest<protocol.CompletionsRequest>(CommandNames.Completions, args);
200-
const response = this.processResponse<protocol.CompletionsResponse>(request);
199+
const request = this.processRequest<protocol.CompletionsRequest>(CommandNames.CompletionInfo, args);
200+
const response = this.processResponse<protocol.CompletionInfoResponse>(request);
201201

202202
return {
203203
isGlobalCompletion: false,
204204
isMemberCompletion: false,
205205
isNewIdentifierLocation: false,
206-
entries: response.body!.map<CompletionEntry>(entry => { // TODO: GH#18217
206+
entries: response.body!.entries.map<CompletionEntry>(entry => { // TODO: GH#18217
207207
if (entry.replacementSpan !== undefined) {
208-
const { name, kind, kindModifiers, sortText, replacementSpan, hasAction, source, data, isRecommended } = entry;
209-
// TODO: GH#241
210-
const res: CompletionEntry = { name, kind, kindModifiers, sortText, replacementSpan: this.decodeSpan(replacementSpan, fileName), hasAction, source, data: data as any, isRecommended };
208+
const res: CompletionEntry = { ...entry, data: entry.data as any, replacementSpan: this.decodeSpan(entry.replacementSpan, fileName) };
211209
return res;
212210
}
213211

tests/cases/fourslash/fourslash.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,8 @@ declare namespace FourSlashInterface {
625625
readonly includeCompletionsForModuleExports?: boolean;
626626
readonly includeCompletionsForImportStatements?: boolean;
627627
readonly includeCompletionsWithSnippetText?: boolean;
628+
readonly includeCompletionsWithInsertText?: boolean;
629+
/** @deprecated use `includeCompletionsWithInsertText` */
628630
readonly includeInsertTextCompletions?: boolean;
629631
readonly includeAutomaticOptionalChainCompletions?: boolean;
630632
readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="../fourslash.ts" />
2+
3+
// @Filename: /project/tsconfig.json
4+
//// { "compilerOptions": { "module": "commonjs" } }
5+
6+
// @Filename: /project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react/index.d.ts
7+
//// export declare function Component(): void;
8+
9+
// @Filename: /project/index.ts
10+
//// Component/**/
11+
12+
// @link: /project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react -> /project/node_modules/@types/react
13+
14+
goTo.marker("");
15+
verify.importFixAtPosition([`import { Component } from "react";\r\n\r\nComponent`]);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// <reference path="../fourslash.ts" />
2+
3+
// @Filename: /project/tsconfig.json
4+
//// { "compilerOptions": { "module": "commonjs" } }
5+
6+
// @Filename: /project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react/index.d.ts
7+
//// export declare function Component(): void;
8+
9+
// @Filename: /project/index.ts
10+
//// [|import Com/**/|]
11+
12+
// @link: /project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react -> /project/node_modules/@types/react
13+
14+
goTo.marker("");
15+
verify.completions({
16+
marker: "",
17+
exact: [{
18+
name: "Component",
19+
source: "react",
20+
insertText: `import { Component$1 } from "react";`,
21+
isSnippet: true,
22+
replacementSpan: test.ranges()[0],
23+
sourceDisplay: "react",
24+
}],
25+
preferences: {
26+
includeCompletionsForImportStatements: true,
27+
includeCompletionsWithInsertText: true,
28+
includeCompletionsWithSnippetText: true,
29+
}
30+
});

0 commit comments

Comments
 (0)