Skip to content

Commit

Permalink
Test: Add tests for go-to-definition for symbols in string content
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonZiweiWang committed Dec 5, 2023
1 parent 5a5fb64 commit bed35b5
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
80 changes: 80 additions & 0 deletions server/src/__tests__/definition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,84 @@ describe('on definition', () => {
])
)
})

it('provides go to definition for symbols found in the string content', async () => {
const parsedHoverPath = path.parse(FIXTURE_DOCUMENT.HOVER.uri.replace('file://', ''))

bitBakeProjectScannerClient.bitbakeScanResult._recipes = [
{
name: parsedHoverPath.name,
path: parsedHoverPath,
appends: [
{
root: parsedHoverPath.root,
dir: parsedHoverPath.dir,
base: 'hover-append.bbappend',
ext: 'bbappend',
name: 'hover-append'
}
],
extraInfo: 'layer: core'
}
]

await analyzer.analyze({
uri: DUMMY_URI,
document: FIXTURE_DOCUMENT.DIRECTIVE
})

const shouldWork1 = onDefinitionHandler({
textDocument: {
uri: DUMMY_URI
},
position: {
line: 7,
character: 21
}
})

const shouldWork2 = onDefinitionHandler({
textDocument: {
uri: DUMMY_URI
},
position: {
line: 8,
character: 22
}
})

const shouldWork3 = onDefinitionHandler({
textDocument: {
uri: DUMMY_URI
},
position: {
line: 9,
character: 14
}
})

const shouldNotWork = onDefinitionHandler({
textDocument: {
uri: DUMMY_URI
},
position: {
line: 9,
character: 31
}
})

expect(shouldWork1).toEqual([
{
uri: FIXTURE_URI.HOVER,
range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }
},
{ range: { end: { character: 0, line: 0 }, start: { character: 0, line: 0 } }, uri: 'file://' + parsedHoverPath.dir + '/hover-append.bbappend' }
])

expect(shouldWork2).toEqual(shouldWork1)

expect(shouldWork3).toEqual(shouldWork1)

expect(shouldNotWork).toEqual([])
})
})
6 changes: 5 additions & 1 deletion server/src/__tests__/fixtures/directive.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ inherit baz

APPEND = 'append bar'
APPEND:append = 'append bar'
FOO = '${APPEND}
FOO = '${APPEND}'
SYMBOL_IN_STRING = 'hover is a package ${FOO} \
parentFolder/hover should also be seen as symbol \
this hover too, other words should not. \
'

0 comments on commit bed35b5

Please sign in to comment.