From b3131edcb5e6fa118df4bee8575e9d618fd60726 Mon Sep 17 00:00:00 2001 From: Ziwei Wang Date: Wed, 8 Nov 2023 15:51:29 -0500 Subject: [PATCH] Chore: Add tests for variables in variable expansion --- server/src/__tests__/fixtures/hover.bb | 6 ++-- server/src/__tests__/hover.test.ts | 40 ++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/server/src/__tests__/fixtures/hover.bb b/server/src/__tests__/fixtures/hover.bb index d020df4f..b7818ca1 100644 --- a/server/src/__tests__/fixtures/hover.bb +++ b/server/src/__tests__/fixtures/hover.bb @@ -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') } diff --git a/server/src/__tests__/hover.test.ts b/server/src/__tests__/hover.test.ts index 62b6605b..b0080707 100644 --- a/server/src/__tests__/hover.test.ts +++ b/server/src/__tests__/hover.test.ts @@ -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 }, @@ -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 @@ -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'