-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import AlignElementsModule from 'diagram-js/lib/features/align-elements'; | ||
import ContextPadModule from 'diagram-js/lib/features/context-pad'; | ||
import PopupMenuModule from 'diagram-js/lib/features/popup-menu'; | ||
|
||
import AlignElementsContextPadProvider from './AlignElementsContextPadProvider'; | ||
import AlignElementsMenuProvider from './AlignElementsMenuProvider'; | ||
|
||
export default { | ||
__depends__: [ | ||
AlignElementsModule, | ||
ContextPadModule | ||
ContextPadModule, | ||
PopupMenuModule | ||
], | ||
__init__: [ | ||
'alignElementsContextPadProvider', | ||
'alignElementsMenuProvider' | ||
], | ||
alignElementsContextPadProvider: [ 'type', AlignElementsContextPadProvider ], | ||
alignElementsMenuProvider: [ 'type', AlignElementsMenuProvider ] | ||
}; | ||
}; |
79 changes: 79 additions & 0 deletions
79
test/spec/features/align-elements/AlignElementsContextPadProviderSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { | ||
bootstrapModeler, | ||
getBpmnJS, | ||
inject | ||
} from 'test/TestHelper'; | ||
|
||
import { | ||
query as domQuery | ||
} from 'min-dom'; | ||
|
||
import alignElementsModule from 'lib/features/align-elements'; | ||
import modelingModule from 'lib/features/modeling'; | ||
import coreModule from 'lib/core'; | ||
|
||
|
||
|
||
describe('features/align-elements - context pad', function() { | ||
|
||
var testModules = [ alignElementsModule, modelingModule, coreModule ]; | ||
|
||
var basicXML = require('../../../fixtures/bpmn/align-elements.bpmn'); | ||
|
||
beforeEach(bootstrapModeler(basicXML, { modules: testModules })); | ||
|
||
|
||
it('should provide button to open menu', inject(function(elementRegistry, contextPad) { | ||
|
||
// given | ||
var elements = [ | ||
elementRegistry.get('EndEvent_lane'), | ||
elementRegistry.get('Task_lane'), | ||
elementRegistry.get('SubProcess_lane') | ||
]; | ||
|
||
// when | ||
contextPad.open(elements); | ||
|
||
// then | ||
expect(getEntry(elements, 'align-elements')).to.exist; | ||
})); | ||
|
||
|
||
it('should NOT provide button if no actions are available', inject( | ||
function(elementRegistry, contextPad, popupMenu) { | ||
|
||
// given | ||
var elements = [ | ||
elementRegistry.get('EndEvent_lane'), | ||
elementRegistry.get('Task_lane'), | ||
elementRegistry.get('SubProcess_lane') | ||
]; | ||
popupMenu.registerProvider('align-elements', 0, { | ||
getPopupMenuEntries: function() { | ||
return function() { | ||
return {}; | ||
}; | ||
} | ||
}); | ||
|
||
// when | ||
contextPad.open(elements); | ||
|
||
// then | ||
expect(getEntry(elements, 'align-elements')).not.to.exist; | ||
}) | ||
); | ||
}); | ||
|
||
|
||
// helper ////////////////////////////////////////////////////////////////////// | ||
function getEntry(target, actionName) { | ||
return padEntry(getBpmnJS().invoke(function(contextPad) { | ||
return contextPad.getPad(target).html; | ||
}), actionName); | ||
} | ||
|
||
function padEntry(element, name) { | ||
return domQuery('[data-action="' + name + '"]', element); | ||
} |