|
| 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 testissue \r\n**strong text** \r\n_italic text_ \r\n<u>underline text</u> \r\n \r\n• Item 1\\. \r\n• Item 2\\. \r\n \r\n[link text](https://google.com) \r\n \r\nRemarks are cool too\\. \r\n \r\nReturns: \r\n a string \r\n \r\nExceptions: \r\n 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