From 72729ce24835ff4e8fc4d2b6cd1bc79bf9618ff7 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 1 Aug 2014 08:32:56 +0200 Subject: [PATCH] fix(modeling/BpmnFactory): do not serialize point#original --- lib/features/modeling/BpmnFactory.js | 2 +- .../spec/features/modeling/BpmnFactorySpec.js | 42 +++++++++---------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/lib/features/modeling/BpmnFactory.js b/lib/features/modeling/BpmnFactory.js index d68e0520..6454e7a0 100644 --- a/lib/features/modeling/BpmnFactory.js +++ b/lib/features/modeling/BpmnFactory.js @@ -69,7 +69,7 @@ BpmnFactory.prototype.createDiWaypoints = function(waypoints) { }; BpmnFactory.prototype.createDiWaypoint = function(point) { - return this.create('dc:Point', point); + return this.create('dc:Point', _.pick(point, [ 'x', 'y' ])); }; diff --git a/test/spec/features/modeling/BpmnFactorySpec.js b/test/spec/features/modeling/BpmnFactorySpec.js index b1a1e9a1..aec08aff 100644 --- a/test/spec/features/modeling/BpmnFactorySpec.js +++ b/test/spec/features/modeling/BpmnFactorySpec.js @@ -11,7 +11,7 @@ var fs = require('fs'); var modelingModule = require('../../../../lib/features/modeling'); -xdescribe('features - bpmn-factory', function() { +describe('features - bpmn-factory', function() { beforeEach(Matchers.addDeepEquals); @@ -23,34 +23,30 @@ xdescribe('features - bpmn-factory', function() { beforeEach(bootstrapBpmnJS(diagramXML, { modules: testModules })); - describe('create task', function() { + describe('create di', function() { - it('should create', inject(function(bpmnFactory) { - var result = bpmnFactory.createNode('bpmn:Task'); + it('should create waypoints', inject(function(bpmnFactory) { - expect(result.semantic.id).toBeDefined(); - expect(result.di.id).toBeDefined(); + // given + var waypoints = [ + { original: { x: 0, y: 0 }, x: 0, y: 0 }, + { original: { x: 0, y: 0 }, x: 0, y: 0 } + ]; - expect(result.di.bounds.width).toBe(100); - expect(result.di.bounds.height).toBe(80); - expect(result.di.bounds.x).toBe(-50); - expect(result.di.bounds.y).toBe(-40); + // when + var result = bpmnFactory.createDiWaypoints(waypoints); + + // then + expect(result).toDeepEqual([ + { $type: 'dc:Point', x: 0, y: 0 }, + { $type: 'dc:Point', x: 0, y: 0 } + ]); + + // expect original not to have been accidently serialized + expect(result[0].$attrs).toEqual({}); })); - it('should create with position', inject(function(bpmnFactory) { - - var result = bpmnFactory.createNode('bpmn:Task', { x: 100, y: 100 }); - - expect(result.semantic.id).toBeDefined(); - expect(result.di.id).toBeDefined(); - - expect(result.di.bounds.width).toBe(100); - expect(result.di.bounds.height).toBe(80); - expect(result.di.bounds.x).toBe(50); - expect(result.di.bounds.y).toBe(60); - })); - }); }); \ No newline at end of file