Skip to content

Commit

Permalink
Fix hover tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Sep 29, 2021
1 parent 8a84ef4 commit 340fd24
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/vscode-bicep/src/test/e2e/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("hover", (): void => {
startCharacter: 6,
endLine: 1,
endCharacter: 12,
contents: ["param vmName: string"],
contents: [codeblock("param vmName: string")],
});
});

Expand All @@ -54,7 +54,7 @@ describe("hover", (): void => {
startCharacter: 4,
endLine: 50,
endCharacter: 22,
contents: ["var linuxConfiguration: object"],
contents: [codeblock("var linuxConfiguration: object")],
});
});

Expand All @@ -69,7 +69,7 @@ describe("hover", (): void => {
startCharacter: 9,
endLine: 108,
endCharacter: 13,
contents: ["resource vnet\nMicrosoft.Network/virtualNetworks@2020-06-01"],
contents: [codeblock("resource vnet\nMicrosoft.Network/virtualNetworks@2020-06-01")],
});
});

Expand All @@ -84,7 +84,7 @@ describe("hover", (): void => {
startCharacter: 7,
endLine: 183,
endCharacter: 28,
contents: ["output administratorUsername: string"],
contents: [codeblock("output administratorUsername: string")],
});
});

Expand All @@ -99,7 +99,11 @@ describe("hover", (): void => {
startCharacter: 55,
endLine: 18,
endCharacter: 67,
contents: ["function uniqueString(string): string"],
contents: [
codeblockWithDescription(
"function uniqueString(string): string",
"Creates a deterministic hash string based on the values provided as parameters.")
],
});
});

Expand Down Expand Up @@ -140,7 +144,7 @@ describe("hover", (): void => {
expect(hover.contents).toHaveLength(contents.length);
hover.contents.forEach((content, contentIndex) => {
expect(normalizeMarkedString(content)).toBe(
marked(contents[contentIndex])
contents[contentIndex]
);
});
});
Expand All @@ -150,7 +154,11 @@ describe("hover", (): void => {
return typeof markedString === "string" ? markedString : markedString.value;
}

function marked(rawString: string): string {
function codeblock(rawString: string): string {
return "```bicep\n" + rawString + "\n```\n";
}

function codeblockWithDescription(rawString: string, description: string): string {
return `${codeblock(rawString)}${description}`;
}
});

0 comments on commit 340fd24

Please sign in to comment.