mirror of
https://github.com/kiteco/vscode-plugin.git
synced 2024-09-11 16:08:10 +03:00
28f70f2d31
* update: typescript to latest * add: ts bundling with ts-loader * add: KiteCodeLensProvider skeleton * change: wip codelens -> prototype inline decoration * update: rm vscode devDep in favor of @types/vscode and vscode-test See https://code.visualstudio.com/updates/v1_36#_splitting-vscode-package-into-typesvscode-and-vscodetest * improve: consolidate after block to avoid conflicting styles Long standing vscode bug "Inline decorations can interfere with one another" https://github.com/microsoft/vscode/issues/33852 * remove: post-install since now using @types/vscode * update: webpack and webpack-cli to latest * migrate: to using vscode-test via webpack transpiling * improve: fix various tests and improve dev test experience * improve: use link theme color for inline message * improve: bump kite-api and use getLineDecoration * add: source-map and typescript test support * migrate: expect.js -> chai for assertion style testing * remove: unused deps + update sinon * test: codenav-decoration
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
import vscode from 'vscode';
|
|
|
|
import { expect } from 'chai';
|
|
import sinon from 'sinon';
|
|
|
|
import EditorEvents from '../src/events';
|
|
import { fixtureURI } from './helpers';
|
|
|
|
describe('EditorEvents', () => {
|
|
let editor, events, Kite;
|
|
|
|
beforeEach(() => {
|
|
// We're going to fake most objects that are used by the editor events
|
|
// because of how VSCode testing environment works.
|
|
// For instance we can't get a reference to the editor of a created document.
|
|
Kite = {
|
|
request: sinon.stub().returns(Promise.resolve()),
|
|
checkState: sinon.stub().returns(Promise.resolve()),
|
|
};
|
|
|
|
const uri = vscode.Uri.file(fixtureURI('sample.py'));
|
|
|
|
return vscode.workspace.openTextDocument(uri)
|
|
.then(doc => {
|
|
editor = {
|
|
document: doc,
|
|
selection: {
|
|
start: new vscode.Position(0,0),
|
|
end: new vscode.Position(0,0),
|
|
},
|
|
};
|
|
|
|
events = new EditorEvents(Kite, editor);
|
|
});
|
|
});
|
|
|
|
it('only sends one event to kited', () => {
|
|
return Promise.all([
|
|
events.selectionChanged(),
|
|
events.edit(),
|
|
])
|
|
.then(() => {
|
|
expect(Kite.request.callCount).to.eql(1);
|
|
|
|
const [, json] = Kite.request.getCall(0).args;
|
|
const payload = JSON.parse(json);
|
|
expect(payload.action).to.eql('edit');
|
|
});
|
|
});
|
|
});
|