Skip to content

Commit c1a4b1a

Browse files
committed
Add a failing test
I wonder if this will even run?
1 parent 149948b commit c1a4b1a

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@
4343
],
4444
"preLaunchTask": "buildDev"
4545
},
46+
{
47+
"name": "Launch Current File BasicRazorApp Integration Tests",
48+
"type": "extensionHost",
49+
"request": "launch",
50+
"runtimeExecutable": "${execPath}",
51+
"args": [
52+
// Create a temp profile that has no extensions / user settings.
53+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
54+
"--profile-temp",
55+
"${workspaceRoot}/test/integrationTests/testAssets/BasicRazorApp2_1/.vscode/lsp_tools_host_BasicRazorApp2_1.code-workspace",
56+
"--extensionDevelopmentPath=${workspaceRoot}",
57+
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests",
58+
],
59+
"env": {
60+
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
61+
"TEST_FILE_FILTER": "${file}"
62+
},
63+
"sourceMaps": true,
64+
"outFiles": [
65+
"${workspaceRoot}/dist/*.js",
66+
"${workspaceRoot}/out/test/**/*.js"
67+
],
68+
"resolveSourceMapLocations": [
69+
"${workspaceFolder}/**",
70+
"!**/node_modules/**"
71+
],
72+
"preLaunchTask": "buildDev"
73+
},
4674
{
4775
"type": "node",
4876
"request": "launch",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 './integrationHelpers';
11+
12+
jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function () {
13+
jestLib.beforeAll(async function () {
14+
const editorConfig = vscode.workspace.getConfiguration('razor');
15+
await editorConfig.update('format.enable', true);
16+
17+
await integrationHelpers.openFileInWorkspaceAsync(path.join('Pages', 'BadlyFormatted.razor'));
18+
await integrationHelpers.activateCSharpExtension();
19+
});
20+
21+
jestLib.afterAll(async () => {
22+
await testAssetWorkspace.cleanupWorkspace();
23+
});
24+
25+
jestLib.test('Document formatted correctly', async () => {
26+
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
27+
return;
28+
}
29+
30+
const activeDocument = vscode.window.activeTextEditor?.document.uri;
31+
if (!activeDocument) {
32+
throw new Error('No active document');
33+
}
34+
const edits: vscode.TextEdit[] = await vscode.commands.executeCommand(
35+
'vscode.executeFormatDocumentProvider',
36+
activeDocument
37+
);
38+
39+
jestLib.expect(edits).toHaveLength(6);
40+
});
41+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"folders": [
3+
{
4+
"path": ".."
5+
}
6+
],
7+
"settings": {
8+
"dotnet.defaultSolution": "BasicRazorApp2_1.sln",
9+
"dotnet.server.trace": "Trace",
10+
"dotnet.server.useOmnisharp": false,
11+
"omnisharp.enableLspDriver": false,
12+
"razor.trace": "Verbose"
13+
}
14+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicRazorApp2_1", "BasicRazorApp2_1.csproj", "{6311A302-9D48-4375-A137-85FF05AED7CF}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{6311A302-9D48-4375-A137-85FF05AED7CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{6311A302-9D48-4375-A137-85FF05AED7CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{6311A302-9D48-4375-A137-85FF05AED7CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{6311A302-9D48-4375-A137-85FF05AED7CF}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

0 commit comments

Comments
 (0)