@@ -15,7 +15,7 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
1515 return ;
1616 }
1717
18- await integrationHelpers . activateCSharpExtension ( ) ;
18+ await integrationHelpers . activateRazorExtension ( ) ;
1919 } ) ;
2020
2121 beforeEach ( async function ( ) {
@@ -32,22 +32,27 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
3232 }
3333
3434 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 ] ;
4535
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+ ) ;
5156 } ) ;
5257
5358 test ( 'Find All References' , async ( ) => {
@@ -56,36 +61,40 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
5661 }
5762
5863 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 ) ;
6675
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+ ) ;
8998 } ) ;
9099
91100 test ( 'Go To Implementation' , async ( ) => {
@@ -94,47 +103,57 @@ integrationHelpers.describeIfWindows(`Razor References ${testAssetWorkspace.desc
94103 }
95104
96105 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- ) ;
104106
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+ ) ;
113127 } ) ;
114128
115129 test ( 'Find All References - CSharp' , async ( ) => {
116130 if ( ! integrationHelpers . isRazorWorkspace ( vscode . workspace ) ) {
117131 return ;
118132 }
119-
133+ const position = new vscode . Position ( 5 , 28 ) ;
120134 await integrationHelpers . openFileInWorkspaceAsync ( path . join ( 'Pages' , 'References.razor.cs' ) ) ;
121135
122- const position = new vscode . Position ( 4 , 20 ) ;
123-
124136 await integrationHelpers . waitForExpectedResult < vscode . Location [ ] > (
125- async ( ) =>
126- await vscode . commands . executeCommand (
137+ async ( ) => {
138+ return await vscode . commands . executeCommand (
127139 'vscode.executeReferenceProvider' ,
128140 vscode . window . activeTextEditor ! . document . uri ,
129141 position
130- ) ,
131- 10000 ,
142+ ) ;
143+ } ,
144+ 1000 ,
132145 100 ,
133146 ( locations ) => {
134147 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 ) ;
138157 }
139158 ) ;
140159 } ) ;
0 commit comments