From 38bff969acf34262ec4a22645cd839d5554e3017 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 30 Jan 2018 13:15:41 +0100 Subject: [PATCH] chore(tests): reformat color tests --- test/spec/features/modeling/SetColorSpec.js | 575 +++++++++++--------- 1 file changed, 317 insertions(+), 258 deletions(-) diff --git a/test/spec/features/modeling/SetColorSpec.js b/test/spec/features/modeling/SetColorSpec.js index 9492bbd6..34b8cd6c 100644 --- a/test/spec/features/modeling/SetColorSpec.js +++ b/test/spec/features/modeling/SetColorSpec.js @@ -13,14 +13,16 @@ describe('features/modeling - set color', function() { var diagramXML = require('../../../fixtures/bpmn/simple.bpmn'); - var testModules = [ coreModule, modelingModule ]; - - beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); + beforeEach(bootstrapModeler(diagramXML, { + modules: [ + coreModule, + modelingModule + ] + })); describe('execute', function() { - it('setting fill color', inject(function(elementRegistry, modeling) { // given @@ -48,48 +50,55 @@ describe('features/modeling - set color', function() { })); - it('setting fill color without changing stroke color', inject(function(elementRegistry, modeling) { + it('setting fill color without changing stroke color', inject( + function(elementRegistry, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - modeling.setColor(taskShape, { fill: 'FUCHSIA', stroke: 'YELLOW' }); + // given + var taskShape = elementRegistry.get('Task_1'); + modeling.setColor(taskShape, { fill: 'FUCHSIA', stroke: 'YELLOW' }); - // when - modeling.setColor(taskShape, { fill: 'YELLOW' }); + // when + modeling.setColor(taskShape, { fill: 'YELLOW' }); - // then - expect(taskShape.businessObject.di.fill).to.equal('YELLOW'); - expect(taskShape.businessObject.di.stroke).to.equal('YELLOW'); - })); + // then + expect(taskShape.businessObject.di.fill).to.equal('YELLOW'); + expect(taskShape.businessObject.di.stroke).to.equal('YELLOW'); + } + )); - it('unsetting fill color without changing stroke color', inject(function(elementRegistry, modeling) { + it('unsetting fill color without changing stroke color', inject( + function(elementRegistry, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - modeling.setColor(taskShape, { fill: 'FUCHSIA', stroke: 'YELLOW' }); + // given + var taskShape = elementRegistry.get('Task_1'); + modeling.setColor(taskShape, { fill: 'FUCHSIA', stroke: 'YELLOW' }); - // when - modeling.setColor(taskShape, { fill: undefined }); + // when + modeling.setColor(taskShape, { fill: undefined }); - // then - expect(taskShape.businessObject.di.fill).not.to.exist; - expect(taskShape.businessObject.di.stroke).to.equal('YELLOW'); - })); + // then + expect(taskShape.businessObject.di.fill).not.to.exist; + expect(taskShape.businessObject.di.stroke).to.equal('YELLOW'); + } + )); - it('unsetting both fill and stroke color', inject(function(elementRegistry, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - modeling.setColor(taskShape, { fill: 'FUCHSIA' }); + it('unsetting both fill and stroke color', inject( + function(elementRegistry, modeling) { - // when - modeling.setColor(taskShape); + // given + var taskShape = elementRegistry.get('Task_1'); + modeling.setColor(taskShape, { fill: 'FUCHSIA' }); - // then - expect(taskShape.businessObject.di.fill).not.to.exist; - expect(taskShape.businessObject.di.stroke).not.to.exist; - })); + // when + modeling.setColor(taskShape); + + // then + expect(taskShape.businessObject.di.fill).not.to.exist; + expect(taskShape.businessObject.di.stroke).not.to.exist; + } + )); it('setting stroke color', inject(function(elementRegistry, modeling) { @@ -121,336 +130,386 @@ describe('features/modeling - set color', function() { })); - it('setting fill color (multiple elements)', inject(function(elementRegistry, modeling) { + it('setting fill color (multiple elements)', inject( + function(elementRegistry, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); - // when - modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); + // when + modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); - // then - expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); - expect(startEventShape.businessObject.di.fill).to.equal('FUCHSIA'); - expect(taskShape.businessObject.di.stroke).not.to.exist; - expect(startEventShape.businessObject.di.stroke).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); + expect(startEventShape.businessObject.di.fill).to.equal('FUCHSIA'); + expect(taskShape.businessObject.di.stroke).not.to.exist; + expect(startEventShape.businessObject.di.stroke).not.to.exist; + } + )); - it('unsetting fill color (multiple elements)', inject(function(elementRegistry, modeling) { + it('unsetting fill color (multiple elements)', inject( + function(elementRegistry, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); - modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); + modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); - // when - modeling.setColor([ taskShape, startEventShape ]); + // when + modeling.setColor([ taskShape, startEventShape ]); - // then - expect(taskShape.businessObject.di.fill).not.to.exist; - expect(startEventShape.businessObject.di.fill).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.fill).not.to.exist; + expect(startEventShape.businessObject.di.fill).not.to.exist; + } + )); - it('setting stroke color (multiple elements)', inject(function(elementRegistry, modeling) { + it('setting stroke color (multiple elements)', inject( + function(elementRegistry, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); - // when - modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); + // when + modeling.setColor([ + taskShape, + startEventShape + ], { stroke: 'FUCHSIA' }); - // then - expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); - expect(startEventShape.businessObject.di.stroke).to.equal('FUCHSIA'); - expect(taskShape.businessObject.di.fill).not.to.exist; - expect(startEventShape.businessObject.di.fill).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); + expect(startEventShape.businessObject.di.stroke).to.equal('FUCHSIA'); + expect(taskShape.businessObject.di.fill).not.to.exist; + expect(startEventShape.businessObject.di.fill).not.to.exist; + } + )); - it('unsetting stroke color (multiple elements)', inject(function(elementRegistry, modeling) { + it('unsetting stroke color (multiple elements)', inject( + function(elementRegistry, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); - modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); + modeling.setColor([ + taskShape, + startEventShape + ], { stroke: 'FUCHSIA' }); - // when - modeling.setColor([ taskShape, startEventShape ]); + // when + modeling.setColor([ taskShape, startEventShape ]); - // then - expect(taskShape.businessObject.di.stroke).not.to.exist; - expect(startEventShape.businessObject.di.stroke).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.stroke).not.to.exist; + expect(startEventShape.businessObject.di.stroke).not.to.exist; + } + )); }); describe('undo', function() { + it('setting fill color', inject( + function(elementRegistry, commandStack, modeling) { - it('setting fill color', inject(function(elementRegistry, commandStack, modeling) { + // given + var taskShape = elementRegistry.get('Task_1'); - // given - var taskShape = elementRegistry.get('Task_1'); + // when + modeling.setColor(taskShape, { fill: 'FUCHSIA' }); + commandStack.undo(); - // when - modeling.setColor(taskShape, { fill: 'FUCHSIA' }); - commandStack.undo(); - - // then - expect(taskShape.businessObject.di.fill).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.fill).not.to.exist; + } + )); - it('unsetting fill color', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting fill color', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - modeling.setColor(taskShape, { fill: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + modeling.setColor(taskShape, { fill: 'FUCHSIA' }); - // when - modeling.setColor(taskShape); - commandStack.undo(); + // when + modeling.setColor(taskShape); + commandStack.undo(); - // then - expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); + } + )); - it('setting stroke color', inject(function(elementRegistry, commandStack, modeling) { + it('setting stroke color', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); + // given + var taskShape = elementRegistry.get('Task_1'); - // when - modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); - commandStack.undo(); + // when + modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); + commandStack.undo(); - // then - expect(taskShape.businessObject.di.stroke).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.stroke).not.to.exist; + } + )); - it('unsetting stroke color', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting stroke color', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); - // when - modeling.setColor(taskShape); - commandStack.undo(); + // when + modeling.setColor(taskShape); + commandStack.undo(); - // then - expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); + } + )); - it('setting fill color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('setting fill color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); - // when - modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); - commandStack.undo(); + // when + modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); + commandStack.undo(); - // then - expect(taskShape.businessObject.di.fill).not.to.exist; - expect(startEventShape.businessObject.di.fill).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.fill).not.to.exist; + expect(startEventShape.businessObject.di.fill).not.to.exist; + } + )); - it('unsetting fill color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting fill color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); - modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); + modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); - // when - modeling.setColor([ taskShape, startEventShape ]); - commandStack.undo(); + // when + modeling.setColor([ taskShape, startEventShape ]); + commandStack.undo(); - // then - expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); - expect(startEventShape.businessObject.di.fill).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); + expect(startEventShape.businessObject.di.fill).to.equal('FUCHSIA'); + } + )); - it('setting stroke color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('setting stroke color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); - // when - modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); - commandStack.undo(); + // when + modeling.setColor([ + taskShape, + startEventShape + ], { stroke: 'FUCHSIA' }); + commandStack.undo(); - // then - expect(taskShape.businessObject.di.stroke).not.to.exist; - expect(startEventShape.businessObject.di.stroke).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.stroke).not.to.exist; + expect(startEventShape.businessObject.di.stroke).not.to.exist; + } + )); - it('unsetting stroke color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting stroke color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); - modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); + modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); - // when - modeling.setColor([ taskShape, startEventShape ]); - commandStack.undo(); + // when + modeling.setColor([ taskShape, startEventShape ]); + commandStack.undo(); - // then - expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); - expect(startEventShape.businessObject.di.stroke).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); + expect(startEventShape.businessObject.di.stroke).to.equal('FUCHSIA'); + } + )); }); describe('redo', function() { + it('setting fill color', inject( + function(elementRegistry, commandStack, modeling) { - it('setting fill color', inject(function(elementRegistry, commandStack, modeling) { + // given + var taskShape = elementRegistry.get('Task_1'); - // given - var taskShape = elementRegistry.get('Task_1'); + // when + modeling.setColor(taskShape, { fill: 'FUCHSIA' }); + commandStack.undo(); + commandStack.redo(); - // when - modeling.setColor(taskShape, { fill: 'FUCHSIA' }); - commandStack.undo(); - commandStack.redo(); - - // then - expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); + } + )); - it('unsetting fill color', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting fill color', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - modeling.setColor(taskShape, { fill: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + modeling.setColor(taskShape, { fill: 'FUCHSIA' }); - // when - modeling.setColor(taskShape); - commandStack.undo(); - commandStack.redo(); + // when + modeling.setColor(taskShape); + commandStack.undo(); + commandStack.redo(); - // then - expect(taskShape.businessObject.di.fill).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.fill).not.to.exist; + } + )); - it('setting stroke color', inject(function(elementRegistry, commandStack, modeling) { + it('setting stroke color', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); + // given + var taskShape = elementRegistry.get('Task_1'); - // when - modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); - commandStack.undo(); - commandStack.redo(); + // when + modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); + commandStack.undo(); + commandStack.redo(); - // then - expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); + } + )); - it('unsetting stroke color', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting stroke color', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + modeling.setColor(taskShape, { stroke: 'FUCHSIA' }); - // when - modeling.setColor(taskShape); - commandStack.undo(); - commandStack.redo(); + // when + modeling.setColor(taskShape); + commandStack.undo(); + commandStack.redo(); - // then - expect(taskShape.businessObject.di.stroke).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.stroke).not.to.exist; + } + )); - it('setting fill color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('setting fill color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); - // when - modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); - commandStack.undo(); - commandStack.redo(); + // when + modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); + commandStack.undo(); + commandStack.redo(); - // then - expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); - expect(startEventShape.businessObject.di.fill).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.fill).to.equal('FUCHSIA'); + expect(startEventShape.businessObject.di.fill).to.equal('FUCHSIA'); + } + )); - it('unsetting fill color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting fill color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); - modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); + modeling.setColor([ taskShape, startEventShape ], { fill: 'FUCHSIA' }); - // when - modeling.setColor([ taskShape, startEventShape ]); - commandStack.undo(); - commandStack.redo(); + // when + modeling.setColor([ taskShape, startEventShape ]); + commandStack.undo(); + commandStack.redo(); - // then - expect(taskShape.businessObject.di.fill).not.to.exist; - expect(startEventShape.businessObject.di.fill).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.fill).not.to.exist; + expect(startEventShape.businessObject.di.fill).not.to.exist; + } + )); - it('setting stroke color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('setting stroke color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); - // when - modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); - commandStack.undo(); - commandStack.redo(); + // when + modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); + commandStack.undo(); + commandStack.redo(); - // then - expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); - expect(startEventShape.businessObject.di.stroke).to.equal('FUCHSIA'); - })); + // then + expect(taskShape.businessObject.di.stroke).to.equal('FUCHSIA'); + expect(startEventShape.businessObject.di.stroke).to.equal('FUCHSIA'); + } + )); - it('unsetting stroke color (multiple elements)', inject(function(elementRegistry, commandStack, modeling) { + it('unsetting stroke color (multiple elements)', inject( + function(elementRegistry, commandStack, modeling) { - // given - var taskShape = elementRegistry.get('Task_1'); - var startEventShape = elementRegistry.get('StartEvent_1'); - modeling.setColor([ taskShape, startEventShape ], { stroke: 'FUCHSIA' }); + // given + var taskShape = elementRegistry.get('Task_1'); + var startEventShape = elementRegistry.get('StartEvent_1'); + modeling.setColor([ + taskShape, + startEventShape + ], { stroke: 'FUCHSIA' }); - // when - modeling.setColor([ taskShape, startEventShape ]); - commandStack.undo(); - commandStack.redo(); + // when + modeling.setColor([ taskShape, startEventShape ]); + commandStack.undo(); + commandStack.redo(); - // then - expect(taskShape.businessObject.di.stroke).not.to.exist; - expect(startEventShape.businessObject.di.stroke).not.to.exist; - })); + // then + expect(taskShape.businessObject.di.stroke).not.to.exist; + expect(startEventShape.businessObject.di.stroke).not.to.exist; + } + )); });