-
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.
feat(data-association-behavior): test integration of both behaviors
- Loading branch information
1 parent
e71da05
commit d1533cb
Showing
1 changed file
with
121 additions
and
0 deletions.
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
test/spec/features/modeling/behavior/DataAssociationBehaviorSpec.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,121 @@ | ||
import { | ||
bootstrapModeler, | ||
inject | ||
} from 'test/TestHelper'; | ||
|
||
import modelingModule from 'lib/features/modeling'; | ||
|
||
import { | ||
getDataInput | ||
} from 'lib/features/modeling/behavior/DataInputAssociationBehavior'; | ||
|
||
import { | ||
getDataOutput | ||
} from 'lib/features/modeling/behavior/DataOutputAssociationBehavior'; | ||
|
||
|
||
describe.only('modeling/behavior - DataInputAssociationBehavior and DataOutputAssociationBehavior integration', function() { | ||
|
||
var diagramXML = require('./DataAssociationBehavior.bpmn'); | ||
|
||
beforeEach(bootstrapModeler(diagramXML, { modules: modelingModule })); | ||
|
||
|
||
it('should add bpmn:DataInput and bpmn:DataOutput on connect -> connect', inject(function(elementRegistry, modeling) { | ||
|
||
// given | ||
var dataObject1 = elementRegistry.get('DataObjectReference_1'), | ||
dataObject2 = elementRegistry.get('DataObjectReference_2'), | ||
task = elementRegistry.get('Task_1'), | ||
taskBo = task.businessObject; | ||
|
||
var dataInputAssociation = modeling.connect(dataObject1, task, { | ||
type: 'bpmn:DataInputAssociation' | ||
}); | ||
|
||
// when | ||
var dataOutputAssociation = modeling.connect(task, dataObject2, { | ||
type: 'bpmn:DataOutputAssociation' | ||
}); | ||
|
||
// then | ||
var dataInputAssociationBo = dataInputAssociation.businessObject, | ||
dataOutputAssociationBo = dataOutputAssociation.businessObject; | ||
|
||
expect(taskBo.ioSpecification).to.exist; | ||
expect(taskBo.ioSpecification.dataInputs).to.have.length(1); | ||
expect(taskBo.ioSpecification.inputSets).to.have.length(1); | ||
expect(taskBo.ioSpecification.inputSets[0].dataInputRefs).to.have.length(1); | ||
expect(taskBo.ioSpecification.dataOutputs).to.have.length(1); | ||
expect(taskBo.ioSpecification.outputSets).to.have.length(1); | ||
expect(taskBo.ioSpecification.outputSets[0].dataOutputRefs).to.have.length(1); | ||
|
||
expect(dataInputAssociationBo.targetRef).to.exist; | ||
expect(dataInputAssociationBo.targetRef).to.eql(getDataInput(taskBo, dataInputAssociationBo.targetRef)); | ||
|
||
expect(dataOutputAssociationBo.get('sourceRef')[0]).to.exist; | ||
expect(dataOutputAssociationBo.get('sourceRef')[0]).to.eql(getDataOutput(taskBo, dataOutputAssociationBo.get('sourceRef')[0])); | ||
})); | ||
|
||
|
||
it('should remove bpmn:DataOutput on connect -> undo', inject(function(commandStack, elementRegistry, modeling) { | ||
|
||
// given | ||
var dataObject1 = elementRegistry.get('DataObjectReference_1'), | ||
dataObject2 = elementRegistry.get('DataObjectReference_2'), | ||
task = elementRegistry.get('Task_1'), | ||
taskBo = task.businessObject; | ||
|
||
var dataInputAssociation = modeling.connect(dataObject1, task, { | ||
type: 'bpmn:DataInputAssociation' | ||
}); | ||
|
||
modeling.connect(task, dataObject2, { | ||
type: 'bpmn:DataOutputAssociation' | ||
}); | ||
|
||
// when | ||
commandStack.undo(); | ||
|
||
// then | ||
var dataInputAssociationBo = dataInputAssociation.businessObject; | ||
|
||
expect(taskBo.ioSpecification).to.exist; | ||
expect(taskBo.ioSpecification.dataInputs).to.have.length(1); | ||
expect(taskBo.ioSpecification.inputSets).to.have.length(1); | ||
expect(taskBo.ioSpecification.inputSets[0].dataInputRefs).to.have.length(1); | ||
expect(taskBo.ioSpecification.dataOutputs).to.not.exist; | ||
expect(taskBo.ioSpecification.outputSets).to.not.exist; | ||
|
||
expect(dataInputAssociationBo.targetRef).to.exist; | ||
expect(dataInputAssociationBo.targetRef).to.eql(getDataInput(taskBo, dataInputAssociationBo.targetRef)); | ||
})); | ||
|
||
|
||
it('should remove bpmn:DataInput and bpmn:DataOutput on connect -> connect -> undo -> undo', inject( | ||
function(commandStack, elementRegistry, modeling) { | ||
|
||
// given | ||
var dataObject1 = elementRegistry.get('DataObjectReference_1'), | ||
dataObject2 = elementRegistry.get('DataObjectReference_2'), | ||
task = elementRegistry.get('Task_1'), | ||
taskBo = task.businessObject; | ||
|
||
modeling.connect(dataObject1, task, { | ||
type: 'bpmn:DataInputAssociation' | ||
}); | ||
|
||
modeling.connect(task, dataObject2, { | ||
type: 'bpmn:DataOutputAssociation' | ||
}); | ||
|
||
// when | ||
commandStack.undo(); | ||
commandStack.undo(); | ||
|
||
// then | ||
expect(taskBo.ioSpecification).not.to.exist; | ||
} | ||
)); | ||
|
||
}); |