From 6205cf0fed41f9246f4f03aed51da64840fb1091 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 4 Feb 2020 14:48:45 -0800 Subject: [PATCH] Add basic insert mode tests --- .../src/test/completions.test.ts | 55 ++++++++++++++----- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/extensions/typescript-language-features/src/test/completions.test.ts b/extensions/typescript-language-features/src/test/completions.test.ts index 7be588facfd..ca307b70d1a 100644 --- a/extensions/typescript-language-features/src/test/completions.test.ts +++ b/extensions/typescript-language-features/src/test/completions.test.ts @@ -30,6 +30,7 @@ namespace Config { export const suggestSelection = 'editor.suggestSelection'; export const completeFunctionCalls = 'typescript.suggest.completeFunctionCalls'; export const autoClosingBrackets = 'editor.autoClosingBrackets'; + export const insertMode = 'editor.suggest.insertMode'; } suite('TypeScript Completions', () => { @@ -37,6 +38,7 @@ suite('TypeScript Completions', () => { [Config.suggestSelection]: 'first', [Config.completeFunctionCalls]: false, [Config.autoClosingBrackets]: 'always', + [Config.insertMode]: 'insert', }); const _disposables: vscode.Disposable[] = []; @@ -180,21 +182,6 @@ suite('TypeScript Completions', () => { )); }); - test.skip('Accepting a member completion should result in valid code. #58597', async () => { - await createTestEditor(testDocumentUri, - `const abc = 123;`, - `ab$0c` - ); - - const document = await acceptFirstSuggestion(testDocumentUri, _disposables); - assert.strictEqual( - document.getText(), - joinLines( - `const abc = 123;`, - `abc` - )); - }); - test('completeFunctionCalls should complete function parameters when at end of word', async () => { await updateConfig({ [Config.completeFunctionCalls]: true, @@ -294,5 +281,43 @@ suite('TypeScript Completions', () => { `}`, )); }); + + test('Accepting a completion in word using insert mode should insert', async () => { + await updateConfig({ + [Config.insertMode]: 'insert', + }); + + await createTestEditor(testDocumentUri, + `const abc = 123;`, + `ab$0c` + ); + + const document = await acceptFirstSuggestion(testDocumentUri, _disposables); + assert.strictEqual( + document.getText(), + joinLines( + `const abc = 123;`, + `abcc` + )); + }); + + test('Accepting a completion in word using replace mode should replace', async () => { + await updateConfig({ + [Config.insertMode]: 'replace', + }); + + await createTestEditor(testDocumentUri, + `const abc = 123;`, + `ab$0c` + ); + + const document = await acceptFirstSuggestion(testDocumentUri, _disposables); + assert.strictEqual( + document.getText(), + joinLines( + `const abc = 123;`, + `abc` + )); + }); });