2015-07-22 16:08:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var TestContainer = require('mocha-test-container-support');
|
|
|
|
|
|
|
|
var coreModule = require('../../../../lib/core'),
|
2016-06-21 13:18:29 +00:00
|
|
|
editorActionsModule = require('../../../../lib/features/editor-actions'),
|
2015-07-22 16:08:53 +00:00
|
|
|
keyboardModule = require('../../../../lib/features/keyboard'),
|
2016-06-21 13:18:29 +00:00
|
|
|
modelingModule = require('../../../../lib/features/modeling');
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2015-08-03 09:49:06 +00:00
|
|
|
var createKeyEvent = require('diagram-js/test/util/KeyEvents').createKeyEvent;
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2015-08-03 09:49:06 +00:00
|
|
|
/* global bootstrapViewer, inject, sinon */
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2016-06-21 13:18:29 +00:00
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
describe('features - keyboard', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
var testModules = [
|
|
|
|
coreModule,
|
2016-06-21 13:18:29 +00:00
|
|
|
editorActionsModule,
|
2015-08-03 09:49:06 +00:00
|
|
|
keyboardModule,
|
2016-06-21 13:18:29 +00:00
|
|
|
modelingModule
|
2015-07-22 16:08:53 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
|
|
|
|
|
2016-06-21 13:18:29 +00:00
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
describe('bpmn key bindings', function() {
|
|
|
|
|
|
|
|
var container;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
container = TestContainer.get(this);
|
|
|
|
});
|
|
|
|
|
2015-10-19 06:09:58 +00:00
|
|
|
it('should include triggers inside editorActions', inject(function(editorActions) {
|
|
|
|
// then
|
2016-08-18 07:08:00 +00:00
|
|
|
expect(editorActions.length()).to.equal(18);
|
2016-04-13 10:36:19 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should trigger lasso tool', inject(function(keyboard, globalConnect) {
|
|
|
|
|
|
|
|
sinon.spy(globalConnect, 'toggle');
|
|
|
|
|
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, 67, false);
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(globalConnect.toggle.calledOnce).to.be.true;
|
2015-10-19 06:09:58 +00:00
|
|
|
}));
|
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
|
|
|
|
it('should trigger lasso tool', inject(function(keyboard, lassoTool) {
|
|
|
|
|
|
|
|
sinon.spy(lassoTool, 'activateSelection');
|
|
|
|
|
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, 76, false);
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(lassoTool.activateSelection.calledOnce).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should trigger space tool', inject(function(keyboard, spaceTool) {
|
|
|
|
|
|
|
|
sinon.spy(spaceTool, 'activateSelection');
|
|
|
|
|
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, 83, false);
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(spaceTool.activateSelection.calledOnce).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should trigger direct editing', inject(function(keyboard, selection, elementRegistry, directEditing) {
|
|
|
|
|
|
|
|
sinon.spy(directEditing, 'activate');
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
selection.select(task);
|
|
|
|
|
|
|
|
var e = createKeyEvent(container, 69, false);
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(directEditing.activate.calledOnce).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should select all elements', inject(function(canvas, keyboard, selection, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, 65, true);
|
|
|
|
|
|
|
|
var allElements = elementRegistry.getAll(),
|
|
|
|
rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var selectedElements = selection.get();
|
|
|
|
|
|
|
|
expect(selectedElements).to.have.length.of(allElements.length - 1);
|
|
|
|
expect(selectedElements).not.to.contain(rootElement);
|
|
|
|
}));
|
|
|
|
|
2016-03-27 14:04:07 +00:00
|
|
|
|
|
|
|
it('should trigger search for labels', inject(function(canvas, keyboard, searchPad, elementRegistry) {
|
|
|
|
|
|
|
|
sinon.spy(searchPad, 'toggle');
|
|
|
|
|
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, 70, true);
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(searchPad.toggle).calledOnce;
|
|
|
|
}));
|
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|