test(context-pad): cleanup provider test case

This commit is contained in:
Nico Rehwaldt 2016-01-06 17:36:11 +01:00
parent bab00633ad
commit 348a0b2d99
1 changed files with 38 additions and 14 deletions

View File

@ -6,15 +6,16 @@ var TestContainer = require('mocha-test-container-support');
var domQuery = require('min-dom/lib/query'); var domQuery = require('min-dom/lib/query');
var is = require('../../../../lib/util/ModelUtil').is;
/* global bootstrapViewer, inject */ /* global bootstrapViewer, inject */
var contextPadModule = require('../../../../lib/features/context-pad'), var contextPadModule = require('../../../../lib/features/context-pad'),
coreModule = require('../../../../lib/core'), coreModule = require('../../../../lib/core'),
modelingModule = require('../../../../lib/features/modeling'), modelingModule = require('../../../../lib/features/modeling'),
popupModule = require('diagram-js/lib/features/popup-menu'), replaceMenuModule = require('../../../../lib/features/popup-menu'),
replaceMenuProvider = require('../../../../lib/features/popup-menu'),
replaceModule = require('diagram-js/lib/features/replace'),
customRulesModule = require('../../../util/custom-rules'); customRulesModule = require('../../../util/custom-rules');
@ -22,15 +23,20 @@ describe('features - context-pad', function() {
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn'); var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
var testModules = [ contextPadModule, coreModule, modelingModule, popupModule, var testModules = [
replaceModule, customRulesModule, replaceMenuProvider ]; coreModule,
modelingModule,
contextPadModule,
replaceMenuModule,
customRulesModule
];
beforeEach(bootstrapViewer(diagramXML, { modules: testModules })); beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
describe('bootstrap', function() { describe('bootstrap', function() {
it('should bootstrap', inject(function(contextPadProvider, replaceMenuProvider) { it('should bootstrap', inject(function(contextPadProvider) {
expect(contextPadProvider).to.exist; expect(contextPadProvider).to.exist;
})); }));
@ -192,18 +198,15 @@ describe('features - context-pad', function() {
})); }));
it('should not inclide control if replacement is disallowed', it('should not include control if replacement is disallowed',
inject(function(elementRegistry, contextPad, customRules) { inject(function(elementRegistry, contextPad, customRules) {
// given // given
var element = elementRegistry.get('StartEvent_1'), var element = elementRegistry.get('StartEvent_1');
padding = 5,
replaceMenuRect,
padMenuRect;
// disallow replacement // disallow replacement
customRules.addRule('shape.replace', function() { customRules.addRule('shape.replace', function(context) {
return false; return !is(context.element, 'bpmn:StartEvent');
}); });
// when // when
@ -215,6 +218,27 @@ describe('features - context-pad', function() {
expect(padEntry(padNode, 'replace')).not.to.exist; expect(padEntry(padNode, 'replace')).not.to.exist;
})); }));
it('should include control if replacement is allowed',
inject(function(elementRegistry, contextPad, customRules) {
// given
var element = elementRegistry.get('EndEvent_1');
// disallow replacement
customRules.addRule('shape.replace', function(context) {
return !is(context.element, 'bpmn:StartEvent');
});
// when
contextPad.open(element);
var padNode = contextPad.getPad(element).html;
// then
expect(padEntry(padNode, 'replace')).to.exist;
}));
}); });
}); });