Skip to content

Commit 32f67db

Browse files
committed
Fix
1 parent 0f7fbbb commit 32f67db

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

test/integrationTests/razorFormatting.integration.test.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function
1515
return;
1616
}
1717

18-
const editorConfig = vscode.workspace.getConfiguration('razor');
19-
await editorConfig.update('format.enable', true);
18+
const razorConfig = vscode.workspace.getConfiguration('razor');
19+
await razorConfig.update('format.enable', true);
20+
const htmlConfig = vscode.workspace.getConfiguration('html');
21+
await htmlConfig.update('format.enable', true);
2022

21-
await integrationHelpers.openFileInWorkspaceAsync(path.join('Pages', 'BadlyFormatted.razor'));
2223
await integrationHelpers.activateCSharpExtension();
24+
await integrationHelpers.openFileInWorkspaceAsync(path.join('Pages', 'BadlyFormatted.razor'));
2325
});
2426

2527
jestLib.afterAll(async () => {
@@ -35,11 +37,35 @@ jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function
3537
if (!activeDocument) {
3638
throw new Error('No active document');
3739
}
38-
const edits: vscode.TextEdit[] = await vscode.commands.executeCommand(
40+
41+
const edits = <vscode.TextEdit[]>await vscode.commands.executeCommand(
3942
'vscode.executeFormatDocumentProvider',
40-
activeDocument
43+
activeDocument,
44+
{
45+
insertSpaces: true,
46+
tabSize: 4,
47+
}
4148
);
4249

43-
jestLib.expect(edits).toHaveLength(6);
50+
jestLib.expect(edits).toBeDefined();
51+
52+
// It's much easier to verify the expected state of the document, than a bunch of edits
53+
const formatEdit = new vscode.WorkspaceEdit();
54+
formatEdit.set(activeDocument, edits);
55+
await vscode.workspace.applyEdit(formatEdit);
56+
57+
const contents = vscode.window.activeTextEditor?.document.getText();
58+
jestLib.expect(contents).toEqual(`@page "/bad"
59+
60+
<div>
61+
<p>
62+
Hello
63+
</p>
64+
</div>
65+
66+
@code {
67+
private string _x = "";
68+
}
69+
`);
4470
});
4571
});

0 commit comments

Comments
 (0)