Skip to content

Commit 1e35af1

Browse files
committed
Uses seperate test case for onHover documentation
1 parent 0b3210a commit 1e35af1

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

server/src/__tests__/server.test.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,22 @@ describe('server', () => {
6767
{} as any,
6868
)
6969

70-
// if user hovers over a function name
71-
// the hover contents should contain
72-
// the comment above the function definition
73-
// see testing/fixtures/comment-doc-on-hover.sh
74-
const commentResult = await onHover(
70+
expect(result).toBeDefined()
71+
expect(result).toEqual({
72+
contents: {
73+
kind: 'markdown',
74+
value: expect.stringContaining('remove directories'),
75+
},
76+
})
77+
})
78+
79+
it('responds to onHover with function documentation extracted from comments', async () => {
80+
const { connection, server } = await initializeServer()
81+
server.register(connection)
82+
83+
const onHover = connection.onHover.mock.calls[0][0]
84+
85+
const result = await onHover(
7586
{
7687
textDocument: {
7788
uri: FIXTURE_URI.COMMENT_DOC,
@@ -87,15 +98,8 @@ describe('server', () => {
8798

8899
expect(result).toBeDefined()
89100
expect(result).toEqual({
90-
contents: {
91-
kind: 'markdown',
92-
value: expect.stringContaining('remove directories'),
93-
},
94-
})
95-
96-
expect(commentResult).toBeDefined()
97-
expect(commentResult).toEqual({
98-
contents: expect.stringContaining('this function takes two arguments'),
101+
contents:
102+
'Function defined on line 8\n\nthis is a comment\ndescribing the function\nhello_world\nthis function takes two arguments',
99103
})
100104
})
101105

0 commit comments

Comments
 (0)