From a9708db766b06521da69be87acbd47b692bd89b6 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Tue, 9 Oct 2018 09:48:34 +0200 Subject: [PATCH] fix(context-pad): fix scaling tests * scaling tests are now actually run --- .../features/context-pad/ContextPadSpec.js | 50 ++++++++----------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/test/spec/features/context-pad/ContextPadSpec.js b/test/spec/features/context-pad/ContextPadSpec.js index 1ba715547..a53c19c30 100755 --- a/test/spec/features/context-pad/ContextPadSpec.js +++ b/test/spec/features/context-pad/ContextPadSpec.js @@ -376,8 +376,6 @@ describe('features/context-pad', function() { describe('scaling', function() { - beforeEach(bootstrapDiagram({ modules: [ contextPadModule, providerModule ] })); - var NUM_REGEX = /[+-]?\d*[.]?\d+(?=,|\))/g; var zoomLevels = [ 1.0, 1.2, 3.5, 10, 0.5 ]; @@ -396,8 +394,13 @@ describe('features/context-pad', function() { return asVector(element.style.transform); } - function verifyScale(expectedScales) { - return inject(function(canvas, contextPad) { + function verifyScale(expectedScales, config) { + var setup = bootstrapDiagram({ + modules: [ contextPadModule, providerModule ], + contextPad: config + }); + + var test = inject(function(canvas, contextPad) { // given var shape = canvas.addShape({ id: 's1', @@ -429,65 +432,52 @@ describe('features/context-pad', function() { expect(effectiveScale).to.be.closeTo(expectedScale, 0.00001); }); }); + + setup(); + test(); } it('should scale within the limits of [ 1.0, 1.5 ] by default', function() { var expectedScales = [ 1.0, 1.2, 1.5, 1.5, 1.0 ]; - bootstrapDiagram({ - modules: [ contextPadModule, providerModule ] - }); - return verifyScale(expectedScales); }); it('should scale within the limits set in config', function() { + var expectedScales = [ 1.0, 1.2, 1.2, 1.2, 1.0 ]; + var config = { scale: { min: 1.0, max: 1.2 } }; - var expectedScales = [ 1.0, 1.2, 1.2, 1.2, 1.0 ]; - - bootstrapDiagram({ - modules: [ contextPadModule, providerModule ], - contextPad: config - }); - return verifyScale(expectedScales); + return verifyScale(expectedScales, config); }); it('should scale with scale = true', function() { + var expectedScales = zoomLevels; + var config = { - scale: false + scale: true }; - var expectedScales = [ 1.0, 1.2, 1.2, 1.2, 1.0 ]; - - bootstrapDiagram({ - modules: [ contextPadModule, providerModule ], - contextPad: config - }); - return verifyScale(expectedScales); + return verifyScale(expectedScales, config); }); it('should not scale with scale = false', function() { + var expectedScales = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; + var config = { scale: false }; - var expectedScales = [ 1.0, 1.2, 1.2, 1.2, 1.0 ]; - - bootstrapDiagram({ - modules: [ contextPadModule, providerModule ], - contextPad: config - }); - return verifyScale(expectedScales); + return verifyScale(expectedScales, config); }); });