Skip to content

Commit

Permalink
test: add code action tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alenakhineika committed Aug 12, 2021
1 parent 1444cf5 commit b7fdfc9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/test/fixture/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"other": true,
"comments": false,
"strings": true
}
},
"security.workspace.trust.enabled": false
}
18 changes: 14 additions & 4 deletions src/test/suite/editors/codeActionProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { beforeEach } from 'mocha';
import chai from 'chai';

import ActiveDBCodeLensProvider from '../../../editors/activeConnectionCodeLensProvider';
import CodeActionProvider from '../../../editors/codeActionProvider';
Expand All @@ -14,6 +14,8 @@ import { StorageController } from '../../../storage';
import TelemetryService from '../../../telemetry/telemetryService';
import { TestExtensionContext, MockLanguageServerController } from '../stubs';

const expect = chai.expect;

suite('Code Action Provider Test Suite', () => {
const mockExtensionContext = new TestExtensionContext();

Expand Down Expand Up @@ -66,14 +68,22 @@ suite('Code Action Provider Test Suite', () => {
const testCodeActionProvider = new CodeActionProvider(testPlaygroundController);
const codeActions = testCodeActionProvider.provideCodeActions();

assert(!codeActions);
expect(codeActions).to.be.undefined;
});

test('expected provideCodeActions to return a run selected playground blocks action', () => {
testPlaygroundController._selectedText = "use('test');";

const testCodeActionProvider = new CodeActionProvider(testPlaygroundController);
const codeActions = testCodeActionProvider.provideCodeActions();

assert(!!codeActions);
assert(codeActions.length === 1);
expect(codeActions).to.exist;

if (codeActions) {
expect(codeActions.length).to.be.equal(1);
const actionCommand = codeActions[0].command;
expect(actionCommand?.command).to.be.equal('mdb.runSelectedPlaygroundBlocks');
expect(actionCommand?.title).to.be.equal('Run selected playground blocks');
}
});
});

0 comments on commit b7fdfc9

Please sign in to comment.