From b3dbff84a4876af88287e408507e5d12c20ba65c Mon Sep 17 00:00:00 2001 From: James Pogran Date: Thu, 11 Apr 2024 10:43:15 -0400 Subject: [PATCH] use an empty file instead of one that needs formatting --- src/test/helper.ts | 20 +++++++++++++++++--- src/test/integration/completion.test.ts | 4 ++-- test/fixtures/empty.tf | 0 test/fixtures/main.tf | 3 +++ 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/empty.tf diff --git a/src/test/helper.ts b/src/test/helper.ts index c2f66681be..a3978ad5aa 100644 --- a/src/test/helper.ts +++ b/src/test/helper.ts @@ -27,13 +27,27 @@ export async function testCompletion( position: vscode.Position, expectedCompletionList: vscode.CompletionList, ) { - const actualCompletionList = (await vscode.commands.executeCommand( + const actualCompletionList = await vscode.commands.executeCommand( 'vscode.executeCompletionItemProvider', docUri, position, - )) as vscode.CompletionList; + ); + + console.log('---actualCompletionList---'); + + actualCompletionList.items.forEach((item) => { + console.log(item.label); + }); + console.log('---'); + + console.log('---expectedCompletionList---'); + + expectedCompletionList.items.forEach((item) => { + console.log(item.label); + }); - assert.equal(actualCompletionList.items.length, expectedCompletionList.items.length); + console.log(`actual: ${actualCompletionList.items.length} expected: ${expectedCompletionList.items.length}`); + assert.deepStrictEqual(actualCompletionList.items.length, expectedCompletionList.items.length); expectedCompletionList.items.forEach((expectedItem, i) => { const actualItem = actualCompletionList.items[i]; assert.deepStrictEqual(actualItem.label, expectedItem.label); diff --git a/src/test/integration/completion.test.ts b/src/test/integration/completion.test.ts index e4bfb40715..723455f4e8 100644 --- a/src/test/integration/completion.test.ts +++ b/src/test/integration/completion.test.ts @@ -17,7 +17,7 @@ const snippets = [ ]; suite('Language Server Completion', function suite() { - const docUri = getDocUri('actions.tf'); + const docUri = getDocUri('empty.tf'); this.beforeAll(async () => { await open(docUri); @@ -48,7 +48,7 @@ suite('Language Server Completion', function suite() { new vscode.CompletionItem('terraform', vscode.CompletionItemKind.Class), new vscode.CompletionItem('variable', vscode.CompletionItemKind.Class), ]; - // expected.push(...snippets); + expected.push(...snippets); await testCompletion(docUri, new vscode.Position(0, 0), { items: expected, }); diff --git a/test/fixtures/empty.tf b/test/fixtures/empty.tf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/main.tf b/test/fixtures/main.tf index f50b96e7b6..39f65a1904 100644 --- a/test/fixtures/main.tf +++ b/test/fixtures/main.tf @@ -20,4 +20,7 @@ module "compute" { instance_name = "terraform-machine" + + } +