@@ -26,7 +26,7 @@ import {
26
26
ShowMessageParams ,
27
27
MessageType ,
28
28
} from "vscode-languageclient/node" ;
29
- import { after , afterEach , before } from "mocha" ;
29
+ import { after , afterEach , before , setup } from "mocha" ;
30
30
31
31
import { Ruby , ManagerIdentifier } from "../../ruby" ;
32
32
import Client from "../../client" ;
@@ -997,4 +997,68 @@ suite("Client", () => {
997
997
998
998
assert . ok ( response . length > 0 ) ;
999
999
} ) . timeout ( 20000 ) ;
1000
+
1001
+ suite ( "goto relevant file" , ( ) => {
1002
+ let testUri : vscode . Uri ;
1003
+ let implUri : vscode . Uri ;
1004
+
1005
+ setup ( ( ) => {
1006
+ testUri = vscode . Uri . joinPath (
1007
+ workspaceUri ,
1008
+ "test" ,
1009
+ "requests" ,
1010
+ "goto_relevant_file_test.rb" ,
1011
+ ) ;
1012
+ implUri = vscode . Uri . joinPath (
1013
+ workspaceUri ,
1014
+ "lib" ,
1015
+ "ruby_lsp" ,
1016
+ "requests" ,
1017
+ "goto_relevant_file.rb" ,
1018
+ ) ;
1019
+ } ) ;
1020
+
1021
+ test ( "for test file" , async ( ) => {
1022
+ const response : { locations : string [ ] } = await client . sendRequest (
1023
+ "experimental/gotoRelevantFile" ,
1024
+ {
1025
+ textDocument : {
1026
+ uri : testUri . toString ( ) ,
1027
+ } ,
1028
+ } ,
1029
+ ) ;
1030
+
1031
+ assert . ok ( response . locations . length === 1 ) ;
1032
+ assert . match ( response . locations [ 0 ] , / l i b \/ r u b y _ l s p \/ r e q u e s t s \/ g o t o _ r e l e v a n t _ f i l e \. r b $ / ) ;
1033
+ } ) ;
1034
+
1035
+ test ( "for implementation file" , async ( ) => {
1036
+ const response : { locations : string [ ] } = await client . sendRequest (
1037
+ "experimental/gotoRelevantFile" ,
1038
+ {
1039
+ textDocument : {
1040
+ uri : implUri . toString ( ) ,
1041
+ } ,
1042
+ } ,
1043
+ ) ;
1044
+
1045
+ assert . ok ( response . locations . length === 1 ) ;
1046
+ assert . match ( response . locations [ 0 ] , / t e s t \/ r e q u e s t s \/ g o t o _ r e l e v a n t _ f i l e _ t e s t \. r b $ / ) ;
1047
+ } ) ;
1048
+
1049
+ test ( "returns empty array for invalid file" , async ( ) => {
1050
+ const uri = vscode . Uri . joinPath ( workspaceUri , "nonexistent" , "file.rb" ) ;
1051
+
1052
+ const response : { locations : string [ ] } = await client . sendRequest (
1053
+ "experimental/gotoRelevantFile" ,
1054
+ {
1055
+ textDocument : {
1056
+ uri : uri . toString ( ) ,
1057
+ } ,
1058
+ } ,
1059
+ ) ;
1060
+
1061
+ assert . deepStrictEqual ( response , { locations : [ ] } ) ;
1062
+ } ) ;
1063
+ } ) ;
1000
1064
} ) ;
0 commit comments