-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable the CodeAction tests that were commented out until the changes in hashicorp/terraform-ls#680 was released.
- Loading branch information
Showing
1 changed file
with
45 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.CodeAction[]>( | ||
// '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.CodeAction[]>( | ||
'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); | ||
} | ||
}); | ||
}); |