From e8f00e763ab992fa74ee4c22b2fe3a97c1ecb268 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 20 Nov 2018 16:43:09 -0800 Subject: [PATCH] Adding pinning test for getting parameters --- .../src/test/functionCallSnippet.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts b/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts index f5da5c7ca19..215a2a3b428 100644 --- a/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts +++ b/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts @@ -44,4 +44,22 @@ suite('typescript function call snippets', () => { ).value, 'bla()$0'); }); + + test('Should extract parameter from display parts', async () => { + assert.strictEqual( + snippetForFunctionCall( + { label: 'activate' }, + [{ "text": "function", "kind": "keyword" }, { "text": " ", "kind": "space" }, { "text": "activate", "kind": "text" }, { "text": "(", "kind": "punctuation" }, { "text": "context", "kind": "parameterName" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "vscode", "kind": "aliasName" }, { "text": ".", "kind": "punctuation" }, { "text": "ExtensionContext", "kind": "interfaceName" }, { "text": ")", "kind": "punctuation" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "void", "kind": "keyword" }] + ).value, + 'activate(${1:context})$0'); + }); + + test('Should extract all parameters from display parts', async () => { + assert.strictEqual( + snippetForFunctionCall( + { label: 'foo' }, + [{ "text": "function", "kind": "keyword" }, { "text": " ", "kind": "space" }, { "text": "foo", "kind": "functionName" }, { "text": "(", "kind": "punctuation" }, { "text": "a", "kind": "parameterName" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "string", "kind": "keyword" }, { "text": ",", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "b", "kind": "parameterName" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "number", "kind": "keyword" }, { "text": ",", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "c", "kind": "parameterName" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "boolean", "kind": "keyword" }, { "text": ")", "kind": "punctuation" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "void", "kind": "keyword" }] + ).value, + 'foo(${1:a}, ${2:b}, ${3:c})$0'); + }); });