Skip to content

Commit 3fc6329

Browse files
authored
Merge pull request #6616 from dotnet/dev/maryamariyan/add-integration-tests
Integration Test - TagHelper Quick Info (Hover)
2 parents 8c42eb1 + 56809d5 commit 3fc6329

File tree

3 files changed

+61
-7
lines changed

3 files changed

+61
-7
lines changed

test/razorIntegrationTests/formatting.integration.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as path from 'path';
77
import * as vscode from 'vscode';
8-
import * as jestLib from '@jest/globals';
8+
import { describe, beforeAll, afterAll, test, expect } from '@jest/globals';
99
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1010
import * as integrationHelpers from '../integrationTests/integrationHelpers';
1111

@@ -21,8 +21,8 @@ function normalizeNewlines(original: string | undefined): string | undefined {
2121
return original;
2222
}
2323

24-
jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function () {
25-
jestLib.beforeAll(async function () {
24+
describe(`Razor Formatting ${testAssetWorkspace.description}`, function () {
25+
beforeAll(async function () {
2626
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
2727
return;
2828
}
@@ -36,11 +36,11 @@ jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function
3636
await integrationHelpers.activateCSharpExtension();
3737
});
3838

39-
jestLib.afterAll(async () => {
39+
afterAll(async () => {
4040
await testAssetWorkspace.cleanupWorkspace();
4141
});
4242

43-
jestLib.test('Document formatted correctly', async () => {
43+
test('Document formatted correctly', async () => {
4444
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
4545
return;
4646
}
@@ -59,7 +59,7 @@ jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function
5959
}
6060
);
6161

62-
jestLib.expect(edits).toBeDefined();
62+
expect(edits).toBeDefined();
6363

6464
console.log(`Got ${edits.length} edits`);
6565

@@ -75,7 +75,7 @@ jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function
7575

7676
console.log(`Checking document contents...`);
7777

78-
jestLib.expect(contents).toBe(
78+
expect(contents).toBe(
7979
normalizeNewlines(`@page "/bad"
8080
8181
@code {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 { describe, beforeAll, afterAll, test, expect } from '@jest/globals';
9+
import testAssetWorkspace from './testAssets/testAssetWorkspace';
10+
import * as integrationHelpers from '../integrationTests/integrationHelpers';
11+
12+
describe(`Razor Hover ${testAssetWorkspace.description}`, function () {
13+
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+
afterAll(async () => {
23+
await testAssetWorkspace.cleanupWorkspace();
24+
});
25+
26+
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: 2,
42+
}
43+
);
44+
45+
expect(hover).toBeDefined();
46+
47+
expect(hover.length).toBe(1);
48+
const first = hover[0];
49+
const answer =
50+
'The input element represents a typed data field, usually with a form control to allow the user to edit the data.';
51+
expect((<{ language: string; value: string }>first.contents[0]).value).toContain(answer);
52+
});
53+
});

test/razorIntegrationTests/testAssets/BasicRazorApp2_1/Pages/Index.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
}
66

77
<h1>@(message)</h1>
8+
<input asp-for="Model.PropertyName" />

0 commit comments

Comments
 (0)