|
| 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 path from 'path'; |
| 7 | +import * as vscode from 'vscode'; |
| 8 | +import * as jestLib from '@jest/globals'; |
| 9 | +import testAssetWorkspace from './testAssets/testAssetWorkspace'; |
| 10 | +import * as integrationHelpers from '../integrationTests/integrationHelpers'; |
| 11 | + |
| 12 | +jestLib.describe(`Razor Hover ${testAssetWorkspace.description}`, function () { |
| 13 | + jestLib.beforeAll(async function () { |
| 14 | + if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) { |
| 15 | + return; |
| 16 | + } |
| 17 | + |
| 18 | + await integrationHelpers.openFileInWorkspaceAsync(path.join('Pages', 'Index.cshtml')); |
| 19 | + await integrationHelpers.activateCSharpExtension(); |
| 20 | + }); |
| 21 | + |
| 22 | + jestLib.afterAll(async () => { |
| 23 | + await testAssetWorkspace.cleanupWorkspace(); |
| 24 | + }); |
| 25 | + |
| 26 | + jestLib.test('Tag Helper Hover', async () => { |
| 27 | + if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) { |
| 28 | + return; |
| 29 | + } |
| 30 | + |
| 31 | + const activeDocument = vscode.window.activeTextEditor?.document.uri; |
| 32 | + if (!activeDocument) { |
| 33 | + throw new Error('No active document'); |
| 34 | + } |
| 35 | + |
| 36 | + const hover = <vscode.Hover[]>await vscode.commands.executeCommand( |
| 37 | + 'vscode.executeHoverProvider', |
| 38 | + activeDocument, |
| 39 | + { |
| 40 | + line: 7, |
| 41 | + character: 16, |
| 42 | + } |
| 43 | + ); |
| 44 | + |
| 45 | + jestLib.expect(hover).toBeDefined(); |
| 46 | + |
| 47 | + jestLib.expect(hover.length).toBe(1); |
| 48 | + const first = hover[0]; |
| 49 | + jestLib.expect(first.contents).toContain('The h1 element represents a section heading.'); |
| 50 | + }); |
| 51 | +}); |
0 commit comments