fix(import/Importer): clear commandStack after import

This commit is contained in:
Nico Rehwaldt 2014-06-18 13:05:32 +02:00
parent 134c65bdd9
commit c7da579f83
2 changed files with 28 additions and 0 deletions

View File

@ -85,6 +85,7 @@ function importBpmnDiagram(diagram, definitions, done) {
var canvas = diagram.get('canvas'); var canvas = diagram.get('canvas');
var events = diagram.get('eventBus'); var events = diagram.get('eventBus');
var commandStack = diagram.get('commandStack');
function addLabel(element, di, data) { function addLabel(element, di, data) {
@ -167,6 +168,8 @@ function importBpmnDiagram(diagram, definitions, done) {
var walker = new BpmnTreeWalker(visitor); var walker = new BpmnTreeWalker(visitor);
walker.handleDefinitions(definitions); walker.handleDefinitions(definitions);
commandStack.clear();
done(); done();
} }

View File

@ -76,4 +76,29 @@ describe('import - importer', function() {
}); });
}); });
it('should clear commandStack after import', function(done) {
// given
var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8');
var diagram = createDiagram();
var commandStack = diagram.get('commandStack');
// when
BpmnModel.fromXML(xml, function(err, definitions) {
if (err) {
return done(err);
}
// when
Importer.importBpmnDiagram(diagram, definitions, function(err) {
expect(commandStack.getStack()).toEqual([]);
done(err);
});
});
});
}); });