Skip to content

Commit 1665982

Browse files
committed
Add fixAll codeAction test
1 parent c6bf8fc commit 1665982

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/lsp/codeAction/basic.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ describe('Should do codeAction', () => {
2121
await testCodeAction(docUri, sameLineRange(5, 6, 6), codeActions);
2222
});
2323

24+
it('finds fixAll codeAction for unused import', async () => {
25+
const codeActions = [{ title: `Delete all unused declarations`, command: 'vetur.chooseTypeScriptCodeAction' }];
26+
await testCodeAction(docUri, sameLineRange(5, 6, 6), codeActions);
27+
});
28+
2429
it('finds codeAction for unused variables', async () => {
2530
const codeActions = [{ title: `Remove declaration for: 'foo'`, command: 'vetur.applyWorkspaceEdits' }];
26-
2731
await testCodeAction(docUri, sameLineRange(7, 6, 6), codeActions);
2832
});
2933
});
@@ -37,16 +41,15 @@ async function testCodeAction(docUri: vscode.Uri, range: vscode.Range, expectedA
3741
// For diagnostics to show up
3842
await sleep(2000);
3943

40-
const result = (await vscode.commands.executeCommand(
41-
'vscode.executeCodeActionProvider',
42-
docUri,
43-
range
44-
)) as CodeAction[];
44+
const result = (await vscode.commands.executeCommand('vscode.executeCodeActionProvider', docUri, range)) as {
45+
title: string;
46+
command: { command: string };
47+
}[];
4548

4649
expectedActions.forEach(eAction => {
4750
assert.ok(
4851
result.some(rAction => {
49-
return rAction.title === eAction.title && rAction.command === eAction.command;
52+
return rAction.title === eAction.title && rAction.command.command === eAction.command;
5053
}),
5154
`Cannot find matching codeAction with title '${eAction.title}'\n` +
5255
`Seen codeActions are:\n${JSON.stringify(result, null, 2)}`

0 commit comments

Comments
 (0)