Skip to content

Commit

Permalink
Chore: Add tests for variables in variable expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonZiweiWang committed Nov 9, 2023
1 parent 2f01e2c commit b3131ed
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
6 changes: 3 additions & 3 deletions server/src/__tests__/fixtures/hover.bb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Should show definiton on hover
DESCRIPTION = 'This is a description'

# Should not show definition on hover
DESCRIPTION = 'This is a description'
MYVAR = "${DESCRIPTION}"
MYVAR:${DESCRIPTION} = 'foo'
python DESCRIPTION(){
print('123')
}
Expand Down
40 changes: 37 additions & 3 deletions server/src/__tests__/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ describe('on hover', () => {
bitBakeDocScanner.clearScannedDocs()
})

it('only shows definition on hovering global variable declaration syntax for bitbake variables after scanning the docs', async () => {
it('shows definition on hovering variable in variable assignment syntax or in variable expansion syntax after scanning the docs', async () => {
bitBakeDocScanner.parseBitbakeVariablesFile()
await analyzer.analyze({
uri: DUMMY_URI,
document: FIXTURE_DOCUMENT.HOVER
})

const shouldShow = await onHoverHandler({
const shouldShow1 = await onHoverHandler({
textDocument: {
uri: DUMMY_URI
},
Expand All @@ -42,6 +42,26 @@ describe('on hover', () => {
}
})

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

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

const shouldNotShow1 = await onHoverHandler({
textDocument: {
uri: DUMMY_URI
Expand Down Expand Up @@ -72,7 +92,21 @@ describe('on hover', () => {
}
})

expect(shouldShow).toEqual({
expect(shouldShow1).toEqual({
contents: {
kind: 'markdown',
value: '**DESCRIPTION**\n___\n A long description for the recipe.\n\n'
}
})

expect(shouldShow2).toEqual({
contents: {
kind: 'markdown',
value: '**DESCRIPTION**\n___\n A long description for the recipe.\n\n'
}
})

expect(shouldShow3).toEqual({
contents: {
kind: 'markdown',
value: '**DESCRIPTION**\n___\n A long description for the recipe.\n\n'
Expand Down

0 comments on commit b3131ed

Please sign in to comment.