Skip to content

Commit

Permalink
Test: Add tests for hover definition for keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonZiweiWang committed Dec 4, 2023
1 parent 9eb0283 commit a4a0a64
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/src/__tests__/fixtures/hover.bb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ def do_build():

my_do_build(){
VAR = 'do_build'
}
}

inherit dummy
include dummy.inc
require dummy.inc
61 changes: 61 additions & 0 deletions server/src/__tests__/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,65 @@ describe('on hover', () => {
expect(shouldNotShow1).toBe(null)
expect(shouldNotShow2).toBe(null)
})

it('should show hover definition for keywords', async () => {
await analyzer.analyze({
uri: DUMMY_URI,
document: FIXTURE_DOCUMENT.HOVER
})

const shouldShow1 = await onHoverHandler({
textDocument: {
uri: DUMMY_URI
},
position: {
line: 30,
character: 1
}
})

const shouldShow2 = await onHoverHandler({
textDocument: {
uri: DUMMY_URI
},
position: {
line: 31,
character: 1
}
})

const shouldShow3 = await onHoverHandler({
textDocument: {
uri: DUMMY_URI
},
position: {
line: 32,
character: 1
}
})

expect(shouldShow1).toEqual(
expect.objectContaining({
contents: expect.objectContaining({
value: expect.stringContaining('inherit')
})
})
)

expect(shouldShow2).toEqual(
expect.objectContaining({
contents: expect.objectContaining({
value: expect.stringContaining('include')
})
})
)

expect(shouldShow3).toEqual(
expect.objectContaining({
contents: expect.objectContaining({
value: expect.stringContaining('require')
})
})
)
})
})

0 comments on commit a4a0a64

Please sign in to comment.