Skip to content

Commit b47f2c4

Browse files
authored
Merge pull request #7480 from dibarbet/hover_tests
Add hover integration tests
2 parents 1e47340 + aa8146f commit b47f2c4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as vscode from 'vscode';
7+
import * as path from 'path';
8+
import testAssetWorkspace from './testAssets/testAssetWorkspace';
9+
import { activateCSharpExtension, closeAllEditorsAsync, openFileInWorkspaceAsync } from './integrationHelpers';
10+
import { describe, beforeAll, beforeEach, afterAll, test, expect, afterEach } from '@jest/globals';
11+
12+
describe(`[${testAssetWorkspace.description}] Hover Tests`, () => {
13+
beforeAll(async () => {
14+
await activateCSharpExtension();
15+
});
16+
17+
beforeEach(async () => {
18+
await openFileInWorkspaceAsync(path.join('src', 'app', 'hover.cs'));
19+
});
20+
21+
afterAll(async () => {
22+
await testAssetWorkspace.cleanupWorkspace();
23+
});
24+
25+
afterEach(async () => {
26+
await closeAllEditorsAsync();
27+
});
28+
29+
test('Hover returns correct documentation', async () => {
30+
const hovers = <vscode.Hover[]>(
31+
await vscode.commands.executeCommand(
32+
'vscode.executeHoverProvider',
33+
vscode.window.activeTextEditor!.document.uri,
34+
new vscode.Position(33, 27)
35+
)
36+
);
37+
38+
const expected =
39+
'```csharp\r\nbool testissue.Compare(int gameObject, string tagName)\r\n```\r\n \r\nA cref&nbsp;testissue \r\n**strong text** \r\n_italic text_ \r\n<u>underline text</u> \r\n \r\n•&nbsp;Item 1\\. \r\n•&nbsp;Item 2\\. \r\n \r\n[link text](https://google.com) \r\n \r\nRemarks are cool too\\. \r\n \r\nReturns: \r\n&nbsp;&nbsp;a string \r\n \r\nExceptions: \r\n&nbsp;&nbsp;NullReferenceException \r\n';
40+
41+
expect(hovers.length).toEqual(1);
42+
expect((hovers[0].contents[0] as vscode.MarkdownString).value).toEqual(expected);
43+
expect(hovers[0].range).toStrictEqual(new vscode.Range(33, 27, 33, 34));
44+
});
45+
});

0 commit comments

Comments
 (0)