@@ -15,7 +15,7 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
15
15
return ;
16
16
}
17
17
18
- await integrationHelpers . activateCSharpExtension ( ) ;
18
+ await integrationHelpers . activateRazorExtension ( ) ;
19
19
} ) ;
20
20
21
21
beforeEach ( async function ( ) {
@@ -32,22 +32,27 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
32
32
}
33
33
34
34
const position = new vscode . Position ( 6 , 41 ) ;
35
- const locations = < vscode . Location [ ] > (
36
- await vscode . commands . executeCommand (
37
- 'vscode.executeDefinitionProvider' ,
38
- vscode . window . activeTextEditor ! . document . uri ,
39
- position
40
- )
41
- ) ;
42
-
43
- expect ( locations . length ) . toBe ( 1 ) ;
44
- const definitionLocation = locations [ 0 ] ;
45
35
46
- expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
47
- expect ( definitionLocation . range . start . line ) . toBe ( 11 ) ;
48
- expect ( definitionLocation . range . start . character ) . toBe ( 16 ) ;
49
- expect ( definitionLocation . range . end . line ) . toBe ( 11 ) ;
50
- expect ( definitionLocation . range . end . character ) . toBe ( 28 ) ;
36
+ await integrationHelpers . waitForExpectedResult < vscode . Location [ ] > (
37
+ async ( ) =>
38
+ await vscode . commands . executeCommand (
39
+ 'vscode.executeDefinitionProvider' ,
40
+ vscode . window . activeTextEditor ! . document . uri ,
41
+ position
42
+ ) ,
43
+ 1000 ,
44
+ 100 ,
45
+ ( locations ) => {
46
+ expect ( locations . length ) . toBe ( 1 ) ;
47
+ const definitionLocation = locations [ 0 ] ;
48
+
49
+ expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
50
+ expect ( definitionLocation . range . start . line ) . toBe ( 11 ) ;
51
+ expect ( definitionLocation . range . start . character ) . toBe ( 16 ) ;
52
+ expect ( definitionLocation . range . end . line ) . toBe ( 11 ) ;
53
+ expect ( definitionLocation . range . end . character ) . toBe ( 28 ) ;
54
+ }
55
+ ) ;
51
56
} ) ;
52
57
53
58
test ( 'Find All References' , async ( ) => {
@@ -56,36 +61,40 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
56
61
}
57
62
58
63
const position = new vscode . Position ( 6 , 41 ) ;
59
- const locations = < vscode . Location [ ] > (
60
- await vscode . commands . executeCommand (
61
- 'vscode.executeReferenceProvider' ,
62
- vscode . window . activeTextEditor ! . document . uri ,
63
- position
64
- )
65
- ) ;
64
+ await integrationHelpers . waitForExpectedResult < vscode . Location [ ] > (
65
+ async ( ) =>
66
+ await vscode . commands . executeCommand (
67
+ 'vscode.executeReferenceProvider' ,
68
+ vscode . window . activeTextEditor ! . document . uri ,
69
+ position
70
+ ) ,
71
+ 1000 ,
72
+ 100 ,
73
+ ( locations ) => {
74
+ expect ( locations . length ) . toBe ( 3 ) ;
66
75
67
- expect ( locations . length ) . toBe ( 3 ) ;
68
-
69
- let definitionLocation = locations [ 0 ] ;
70
- expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
71
- expect ( definitionLocation . range . start . line ) . toBe ( 6 ) ;
72
- expect ( definitionLocation . range . start . character ) . toBe ( 33 ) ;
73
- expect ( definitionLocation . range . end . line ) . toBe ( 6 ) ;
74
- expect ( definitionLocation . range . end . character ) . toBe ( 45 ) ;
75
-
76
- definitionLocation = locations [ 1 ] ;
77
- expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
78
- expect ( definitionLocation . range . start . line ) . toBe ( 11 ) ;
79
- expect ( definitionLocation . range . start . character ) . toBe ( 16 ) ;
80
- expect ( definitionLocation . range . end . line ) . toBe ( 11 ) ;
81
- expect ( definitionLocation . range . end . character ) . toBe ( 28 ) ;
82
-
83
- definitionLocation = locations [ 2 ] ;
84
- expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
85
- expect ( definitionLocation . range . start . line ) . toBe ( 15 ) ;
86
- expect ( definitionLocation . range . start . character ) . toBe ( 8 ) ;
87
- expect ( definitionLocation . range . end . line ) . toBe ( 15 ) ;
88
- expect ( definitionLocation . range . end . character ) . toBe ( 20 ) ;
76
+ let definitionLocation = locations [ 0 ] ;
77
+ expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
78
+ expect ( definitionLocation . range . start . line ) . toBe ( 6 ) ;
79
+ expect ( definitionLocation . range . start . character ) . toBe ( 33 ) ;
80
+ expect ( definitionLocation . range . end . line ) . toBe ( 6 ) ;
81
+ expect ( definitionLocation . range . end . character ) . toBe ( 45 ) ;
82
+
83
+ definitionLocation = locations [ 1 ] ;
84
+ expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
85
+ expect ( definitionLocation . range . start . line ) . toBe ( 11 ) ;
86
+ expect ( definitionLocation . range . start . character ) . toBe ( 16 ) ;
87
+ expect ( definitionLocation . range . end . line ) . toBe ( 11 ) ;
88
+ expect ( definitionLocation . range . end . character ) . toBe ( 28 ) ;
89
+
90
+ definitionLocation = locations [ 2 ] ;
91
+ expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
92
+ expect ( definitionLocation . range . start . line ) . toBe ( 15 ) ;
93
+ expect ( definitionLocation . range . start . character ) . toBe ( 8 ) ;
94
+ expect ( definitionLocation . range . end . line ) . toBe ( 15 ) ;
95
+ expect ( definitionLocation . range . end . character ) . toBe ( 20 ) ;
96
+ }
97
+ ) ;
89
98
} ) ;
90
99
91
100
test ( 'Go To Implementation' , async ( ) => {
@@ -94,47 +103,57 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
94
103
}
95
104
96
105
const position = new vscode . Position ( 18 , 18 ) ;
97
- const locations = < vscode . Location [ ] > (
98
- await vscode . commands . executeCommand (
99
- 'vscode.executeImplementationProvider' ,
100
- vscode . window . activeTextEditor ! . document . uri ,
101
- position
102
- )
103
- ) ;
104
106
105
- expect ( locations . length ) . toBe ( 1 ) ;
106
- const definitionLocation = locations [ 0 ] ;
107
-
108
- expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
109
- expect ( definitionLocation . range . start . line ) . toBe ( 23 ) ;
110
- expect ( definitionLocation . range . start . character ) . toBe ( 10 ) ;
111
- expect ( definitionLocation . range . end . line ) . toBe ( 23 ) ;
112
- expect ( definitionLocation . range . end . character ) . toBe ( 19 ) ;
107
+ await integrationHelpers . waitForExpectedResult < vscode . Location [ ] > (
108
+ async ( ) =>
109
+ await vscode . commands . executeCommand (
110
+ 'vscode.executeImplementationProvider' ,
111
+ vscode . window . activeTextEditor ! . document . uri ,
112
+ position
113
+ ) ,
114
+ 1000 ,
115
+ 100 ,
116
+ ( locations ) => {
117
+ expect ( locations . length ) . toBe ( 1 ) ;
118
+ const definitionLocation = locations [ 0 ] ;
119
+
120
+ expect ( definitionLocation . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
121
+ expect ( definitionLocation . range . start . line ) . toBe ( 23 ) ;
122
+ expect ( definitionLocation . range . start . character ) . toBe ( 10 ) ;
123
+ expect ( definitionLocation . range . end . line ) . toBe ( 23 ) ;
124
+ expect ( definitionLocation . range . end . character ) . toBe ( 19 ) ;
125
+ }
126
+ ) ;
113
127
} ) ;
114
128
115
129
test ( 'Find All References - CSharp' , async ( ) => {
116
130
if ( ! integrationHelpers . isRazorWorkspace ( vscode . workspace ) ) {
117
131
return ;
118
132
}
119
-
133
+ const position = new vscode . Position ( 5 , 28 ) ;
120
134
await integrationHelpers . openFileInWorkspaceAsync ( path . join ( 'Pages' , 'References.razor.cs' ) ) ;
121
135
122
- const position = new vscode . Position ( 4 , 20 ) ;
123
-
124
136
await integrationHelpers . waitForExpectedResult < vscode . Location [ ] > (
125
- async ( ) =>
126
- await vscode . commands . executeCommand (
137
+ async ( ) => {
138
+ return await vscode . commands . executeCommand (
127
139
'vscode.executeReferenceProvider' ,
128
140
vscode . window . activeTextEditor ! . document . uri ,
129
141
position
130
- ) ,
131
- 10000 ,
142
+ ) ;
143
+ } ,
144
+ 1000 ,
132
145
100 ,
133
146
( locations ) => {
134
147
expect ( locations . length ) . toBe ( 3 ) ;
135
- expect ( locations [ 0 ] . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
136
- expect ( locations [ 1 ] . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
137
- expect ( locations [ 2 ] . uri . path ) . toBe ( vscode . window . activeTextEditor ! . document . uri . path ) ;
148
+
149
+ const sortedLocations = integrationHelpers . sortLocations ( locations ) ;
150
+
151
+ const razorFile = integrationHelpers . getFilePath ( path . join ( 'Pages' , 'References.razor' ) ) ;
152
+ const csharpFile = integrationHelpers . getFilePath ( path . join ( 'Pages' , 'References.razor.cs' ) ) ;
153
+
154
+ expect ( sortedLocations [ 0 ] . uri . path ) . toBe ( razorFile . path ) ;
155
+ expect ( sortedLocations [ 1 ] . uri . path ) . toBe ( csharpFile . path ) ;
156
+ expect ( sortedLocations [ 2 ] . uri . path ) . toBe ( csharpFile . path ) ;
138
157
}
139
158
) ;
140
159
} ) ;
0 commit comments