@@ -965,8 +965,7 @@ describe('server', () => {
965
965
} )
966
966
967
967
it ( 'displays correct documentation for symbols in file that override path executables' , async ( ) => {
968
- const { connection, server } = await initializeServer ( )
969
- server . register ( connection )
968
+ const { connection } = await initializeServer ( )
970
969
971
970
const onHover = connection . onHover . mock . calls [ 0 ] [ 0 ]
972
971
@@ -1000,31 +999,70 @@ describe('server', () => {
1000
999
} )
1001
1000
1002
1001
it ( 'returns executable documentation if the function is not redefined' , async ( ) => {
1003
- const { connection, server } = await initializeServer ( )
1004
- server . register ( connection )
1002
+ const { connection } = await initializeServer ( )
1005
1003
1006
1004
const onHover = connection . onHover . mock . calls [ 0 ] [ 0 ]
1007
1005
1008
- const result = await onHover (
1009
- {
1010
- textDocument : {
1011
- uri : FIXTURE_URI . OVERRIDE_SYMBOL ,
1006
+ const getHoverResult = ( position : LSP . Position ) =>
1007
+ onHover (
1008
+ {
1009
+ textDocument : {
1010
+ uri : FIXTURE_URI . OVERRIDE_SYMBOL ,
1011
+ } ,
1012
+ position,
1012
1013
} ,
1013
- position : {
1014
- line : 2 ,
1015
- character : 1 ,
1014
+ { } as any ,
1015
+ { } as any ,
1016
+ )
1017
+
1018
+ const result1 = await getHoverResult ( { line : 2 , character : 1 } )
1019
+ expect ( result1 ) . toBeDefined ( )
1020
+ expect ( ( result1 as any ) ?. contents . value ) . toContain ( 'list directory contents' )
1021
+
1022
+ // return null same result if the cursor is on the arguments
1023
+ const result2 = await getHoverResult ( { line : 2 , character : 3 } )
1024
+ expect ( result2 ) . toBeDefined ( )
1025
+ expect ( ( result2 as any ) ?. contents . value ) . toBeUndefined ( )
1026
+ } )
1027
+
1028
+ it . skip ( 'returns documentation from explainshell' , async ( ) => {
1029
+ // Skipped as this requires a running explainshell server
1030
+ // docker container run --name explainshell --restart always -p 127.0.0.1:6000:5000 -d spaceinvaderone/explainshell
1031
+
1032
+ const { connection } = await initializeServer ( {
1033
+ capabilities : {
1034
+ workspace : {
1035
+ configuration : true ,
1016
1036
} ,
1017
1037
} ,
1018
- { } as any ,
1019
- { } as any ,
1020
- )
1038
+ configurationObject : {
1039
+ explainshellEndpoint : 'http://localhost:6000' ,
1040
+ } ,
1041
+ } )
1042
+ const onHover = connection . onHover . mock . calls [ 0 ] [ 0 ]
1021
1043
1022
- expect ( result ) . toBeDefined ( )
1023
- expect ( ( result as any ) ?. contents . value ) . toContain ( 'list directory contents' )
1024
- } )
1044
+ const getHoverResult = ( position : LSP . Position ) =>
1045
+ onHover (
1046
+ {
1047
+ textDocument : {
1048
+ uri : FIXTURE_URI . OVERRIDE_SYMBOL ,
1049
+ } ,
1050
+ position,
1051
+ } ,
1052
+ { } as any ,
1053
+ { } as any ,
1054
+ )
1025
1055
1026
- it . skip ( 'returns documentation from explainshell' , ( ) => {
1027
- // FIXME
1056
+ const result1 = await getHoverResult ( { line : 2 , character : 1 } )
1057
+ expect ( result1 ) . toBeDefined ( )
1058
+ expect ( ( result1 as any ) ?. contents . value ) . toEqual ( 'list directory contents' )
1059
+
1060
+ // return explain shell result for the arguments
1061
+ const result2 = await getHoverResult ( { line : 2 , character : 3 } )
1062
+ expect ( result2 ) . toBeDefined ( )
1063
+ expect ( ( result2 as any ) ?. contents . value ) . toEqual (
1064
+ '**\\-l** use a long listing format' ,
1065
+ )
1028
1066
} )
1029
1067
} )
1030
1068
0 commit comments