diff --git a/src/test/xrefCompletionProvider.test.ts b/src/test/xrefCompletionProvider.test.ts index a4cc3137..6745637d 100644 --- a/src/test/xrefCompletionProvider.test.ts +++ b/src/test/xrefCompletionProvider.test.ts @@ -51,7 +51,7 @@ suite('Xref CompletionsProvider', () => { label: 'aShortHandID[]', }) }) - test('Should return ids declared using the longhand syntax as completion after "xref:"', async () => { + test('Should return ids declared using the longhand syntax as completion after "xref:" from other document', async () => { const fileToAutoComplete = vscode.Uri.file(`${root}/fileToAutoComplete.adoc`) await vscode.workspace.fs.writeFile(fileToAutoComplete, Buffer.from('xref:')) createdFiles.push(fileToAutoComplete) @@ -63,6 +63,22 @@ suite('Xref CompletionsProvider', () => { const file = await vscode.workspace.openTextDocument(fileToAutoComplete) const completionsItems = await xrefProvider.provideCompletionItems(file, new Position(0, 5)) const filteredCompletionItems = completionsItems.filter((completionItem) => completionItem.label === 'longHandID[]') + assert.deepStrictEqual(filteredCompletionItems[0], { + kind: vscode.CompletionItemKind.Reference, + label: 'longHandID[]', + insertText: 'fileToAppearInAutoComplete.adoc#longHandID[]', + }) + }) + test('Should return ids declared using the longhand syntax as completion after "xref:" from same document', async () => { + const fileToAutoComplete = vscode.Uri.file(`${root}/fileToAutoCompleteFromSameFile.adoc`) + await vscode.workspace.fs.writeFile(fileToAutoComplete, Buffer.from(`[id=longHandID] + +xref:`)) + createdFiles.push(fileToAutoComplete) + + const file = await vscode.workspace.openTextDocument(fileToAutoComplete) + const completionsItems = await xrefProvider.provideCompletionItems(file, new Position(2, 5)) + const filteredCompletionItems = completionsItems.filter((completionItem) => completionItem.label === 'longHandID[]') assert.deepStrictEqual(filteredCompletionItems[0], { kind: vscode.CompletionItemKind.Reference, label: 'longHandID[]',