@@ -15,11 +15,13 @@ jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function
15
15
return ;
16
16
}
17
17
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 ) ;
20
22
21
- await integrationHelpers . openFileInWorkspaceAsync ( path . join ( 'Pages' , 'BadlyFormatted.razor' ) ) ;
22
23
await integrationHelpers . activateCSharpExtension ( ) ;
24
+ await integrationHelpers . openFileInWorkspaceAsync ( path . join ( 'Pages' , 'BadlyFormatted.razor' ) ) ;
23
25
} ) ;
24
26
25
27
jestLib . afterAll ( async ( ) => {
@@ -35,11 +37,35 @@ jestLib.describe(`Razor Formatting ${testAssetWorkspace.description}`, function
35
37
if ( ! activeDocument ) {
36
38
throw new Error ( 'No active document' ) ;
37
39
}
38
- const edits : vscode . TextEdit [ ] = await vscode . commands . executeCommand (
40
+
41
+ const edits = < vscode . TextEdit [ ] > await vscode . commands . executeCommand (
39
42
'vscode.executeFormatDocumentProvider' ,
40
- activeDocument
43
+ activeDocument ,
44
+ {
45
+ insertSpaces : true ,
46
+ tabSize : 4 ,
47
+ }
41
48
) ;
42
49
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
+ ` ) ;
44
70
} ) ;
45
71
} ) ;
0 commit comments