Skip to content

Commit

Permalink
Clean up signature help test (#2117)
Browse files Browse the repository at this point in the history
* Added parameter

* modifications

* Cleaned up tests
  • Loading branch information
akshita31 authored Mar 19, 2018
1 parent 341d646 commit da32489
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
60 changes: 30 additions & 30 deletions test/integrationTests/signatureHelp.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,59 +35,59 @@ suite(`SignatureHelp: ${testAssetWorkspace.description}`, function () {
await vscode.commands.executeCommand("vscode.open", fileUri);
});


test("Returns response with documentation as undefined when method does not have documentation", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 23));
let c = await GetSignatureHelp(fileUri, new vscode.Position(19, 23));
expect(c.signatures[0].documentation).to.be.undefined;
});

test("Returns label when method does not have documentation", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 23));
let answer = `void sigHelp.noDocMethod()`;
expect(c.signatures[0].label).to.equal(answer);
let c = await GetSignatureHelp(fileUri, new vscode.Position(19, 23));
expect(c.signatures[0].label).to.equal(`void sigHelp.noDocMethod()`);
});

test("Returns summary as documentation for the method", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(18, 18));
let answer = `DoWork is some method.`;
expect(c.signatures[0].documentation).to.equal(answer);
let c = await GetSignatureHelp(fileUri, new vscode.Position(18, 18));
expect(c.signatures[0].documentation).to.equal(`DoWork is some method.`);
});

test("Returns label for the method", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(18, 18));
let answer = `void sigHelp.DoWork(int Int1, float Float1)`;
expect(c.signatures[0].label).to.equal(answer);
let c = await GetSignatureHelp(fileUri, new vscode.Position(18, 18));
expect(c.signatures[0].label).to.equal(`void sigHelp.DoWork(int Int1, float Float1, double Double1)`);
});

test("Returns label for the parameters", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(18, 18));
let param1 = `int Int1`;
let param2 = `float Float1`;
expect(c.signatures[0].parameters[0].label).to.equal(param1);
expect(c.signatures[0].parameters[1].label).to.equal(param2);
let c = await GetSignatureHelp(fileUri, new vscode.Position(18, 18));
expect(c.signatures[0].parameters[0].label).to.equal(`int Int1`);
expect(c.signatures[0].parameters[1].label).to.equal(`float Float1`);
});

test("Returns documentation for the parameters", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(18, 18));
let param1 = `**Int1**: Used to indicate status.`;
let param2 = `**Float1**: Used to specify context.`;
expect((<vscode.MarkdownString> c.signatures[0].parameters[0].documentation).value).to.equal(param1);
expect((<vscode.MarkdownString> c.signatures[0].parameters[1].documentation).value).to.equal(param2);
let c = await GetSignatureHelp(fileUri, new vscode.Position(18, 18));
expect((<vscode.MarkdownString>c.signatures[0].parameters[0].documentation).value).to.equal(`**Int1**: Used to indicate status.`);
expect((<vscode.MarkdownString>c.signatures[0].parameters[1].documentation).value).to.equal(`**Float1**: Used to specify context.`);
});

test("Signature Help identifies active parameter if there is no comma", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(18, 18));
let answer = `int Int1`;
expect(c.signatures[0].parameters[c.activeParameter].label).to.equal(answer);
let c = await GetSignatureHelp(fileUri, new vscode.Position(18, 18));
expect(c.signatures[0].parameters[c.activeParameter].label).to.equal(`int Int1`);
});

test("Signature Help identifies active parameter based on comma", async function () {
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(18, 20));
let answer = `float Float1`;
expect(c.signatures[0].parameters[c.activeParameter].label).to.equal(answer);
let c = await GetSignatureHelp(fileUri, new vscode.Position(18, 20));
expect(c.signatures[0].parameters[c.activeParameter].label).to.equal(`float Float1`);
});

suiteTeardown(async () => {
await testAssetWorkspace.cleanupWorkspace();
test("Signature Help identifies active parameter based on comma for multiple commas", async function () {
let c = await GetSignatureHelp(fileUri, new vscode.Position(18, 27));
expect(c.signatures[0].parameters[c.activeParameter].label).to.equal(`double Double1`);
});
});
});

suiteTeardown(async () => {
await testAssetWorkspace.cleanupWorkspace();
});

async function GetSignatureHelp(fileUri: vscode.Uri, position: vscode.Position) {
return <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, position);
}
4 changes: 2 additions & 2 deletions test/integrationTests/testAssets/singleCsproj/sigHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class sigHelp
///<summary>DoWork is some method.</summary>
/// <param name="Int1">Used to indicate status.</param>
/// <param name="Float1">Used to specify context.</param>
public static void DoWork(int Int1, float Float1)
public static void DoWork(int Int1, float Float1, double Double1)
{
}

Expand All @@ -16,7 +16,7 @@ public static void noDocMethod()

public static void main()
{
DoWork(4, 4.0f);
DoWork(4, 4.0f, 5.0);
noDocMethod();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class sigHelp
///<summary>DoWork is some method.</summary>
/// <param name="Int1">Used to indicate status.</param>
/// <param name="Float1">Used to specify context.</param>
public static void DoWork(int Int1, float Float1)
public static void DoWork(int Int1, float Float1, double Double1)
{
}

Expand All @@ -16,7 +16,7 @@ public static void noDocMethod()

public static void main()
{
DoWork(4, 4.0f);
DoWork(4, 4.0f, 5.0);
noDocMethod();
}
}
Expand Down

0 comments on commit da32489

Please sign in to comment.