From 0d79aaf34cd34c727b542d0e5e83b111f9d4b669 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 10 Nov 2021 10:26:30 -0500 Subject: [PATCH] Enable CodeAction tests Enable the CodeAction tests that were commented out until the changes in https://github.com/hashicorp/terraform-ls/pull/680 was released. --- src/test/integration/codeAction.test.ts | 92 ++++++++++++------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/test/integration/codeAction.test.ts b/src/test/integration/codeAction.test.ts index f693678d1..aa8298835 100644 --- a/src/test/integration/codeAction.test.ts +++ b/src/test/integration/codeAction.test.ts @@ -1,47 +1,45 @@ -// import * as vscode from 'vscode'; -// import * as assert from 'assert'; -// import { expect } from 'chai'; -// import { getDocUri, open } from '../helper'; -// import { config } from '../../vscodeUtils'; - -// Enable when https://github.com/hashicorp/terraform-ls/pull/680 is merged -// suite('code actions', () => { -// teardown(async () => { -// await vscode.commands.executeCommand('workbench.action.closeAllEditors'); -// }); - -// test('supported actions', async () => { -// await vscode.workspace -// .getConfiguration('terraform') -// .update('languageServer', { external: true }, vscode.ConfigurationTarget.Workspace); -// await vscode.workspace -// .getConfiguration('editor') -// .update('codeActionsOnSave', { "source.formatAll.terraform": true }, vscode.ConfigurationTarget.Workspace); - -// const docUri = getDocUri('actions.tf'); -// await open(docUri); - -// const supported = [ -// new vscode.CodeAction('Format Document', vscode.CodeActionKind.Source.append('formatAll').append('terraform')), -// ]; - -// for (let index = 0; index < supported.length; index++) { -// const wanted = supported[index]; -// const requested = wanted.kind.value.toString(); - -// const actions: vscode.CodeAction[] = await vscode.commands.executeCommand( -// 'vscode.executeCodeActionProvider', -// docUri, -// new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)), -// requested, -// ); - -// assert.ok(actions); -// expect(actions).not.to.be.undefined; - -// assert.strictEqual(actions.length, 1); -// assert.strictEqual(actions[0].title, wanted.title); -// assert.strictEqual(actions[0].kind.value, wanted.kind.value); -// } -// }); -// }); +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { expect } from 'chai'; +import { getDocUri, open } from '../helper'; + +suite('code actions', () => { + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('supported actions', async () => { + await vscode.workspace + .getConfiguration('terraform') + .update('languageServer', { external: true }, vscode.ConfigurationTarget.Workspace); + await vscode.workspace + .getConfiguration('editor') + .update('codeActionsOnSave', { "source.formatAll.terraform": true }, vscode.ConfigurationTarget.Workspace); + + const docUri = getDocUri('actions.tf'); + await open(docUri); + + const supported = [ + new vscode.CodeAction('Format Document', vscode.CodeActionKind.Source.append('formatAll').append('terraform')), + ]; + + for (let index = 0; index < supported.length; index++) { + const wanted = supported[index]; + const requested = wanted.kind.value.toString(); + + const actions: vscode.CodeAction[] = await vscode.commands.executeCommand( + 'vscode.executeCodeActionProvider', + docUri, + new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)), + requested, + ); + + assert.ok(actions); + expect(actions).not.to.be.undefined; + + assert.strictEqual(actions.length, 1); + assert.strictEqual(actions[0].title, wanted.title); + assert.strictEqual(actions[0].kind.value, wanted.kind.value); + } + }); +});