diff --git a/server/src/__tests__/completions.test.ts b/server/src/__tests__/completions.test.ts index 74182e13..3ffb70f7 100644 --- a/server/src/__tests__/completions.test.ts +++ b/server/src/__tests__/completions.test.ts @@ -31,6 +31,10 @@ describe('On Completion', () => { bitBakeDocScanner.clearScannedDocs() }) + afterEach(() => { + jest.restoreAllMocks() + }) + it('expects reserved variables, keywords and snippets in completion item lists', async () => { // nothing is analyzed yet, and docs are not scanned. Only the static and fallback completion items are provided const result = onCompletionHandler({ diff --git a/server/src/__tests__/definition.test.ts b/server/src/__tests__/definition.test.ts index 0e2844df..a28909f8 100644 --- a/server/src/__tests__/definition.test.ts +++ b/server/src/__tests__/definition.test.ts @@ -7,17 +7,16 @@ import { analyzer } from '../tree-sitter/analyzer' import { generateParser } from '../tree-sitter/parser' import { onDefinitionHandler } from '../connectionHandlers/onDefinition' import { FIXTURE_DOCUMENT } from './fixtures/fixtures' -import contextHandler from '../ContextHandler' import { type Location } from 'vscode-languageserver' - +import { definitionProvider } from '../DefinitionProvider' // TODO: Current implementation of the definitionProvider needs to be improved, this test suite should be modified accordingly after const mockDefinition = (path: string | undefined): void => { if (path !== undefined) { const location: Location = { uri: 'file://' + path, range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } } } - jest.spyOn(contextHandler, 'getDefinitionForDirectives').mockReturnValueOnce(location) + jest.spyOn(definitionProvider, 'createDefinitionForKeyword').mockReturnValue(location) } else { - jest.spyOn(contextHandler, 'getDefinitionForDirectives').mockReturnValueOnce([]) + jest.spyOn(definitionProvider, 'createDefinitionForKeyword').mockReturnValue([]) } } @@ -35,6 +34,10 @@ describe('on definition', () => { analyzer.resetAnalyzedDocuments() }) + afterEach(() => { + jest.resetAllMocks() + }) + it('provides definition to directive statement', async () => { await analyzer.analyze({ uri: DUMMY_URI,