Skip to content

Commit

Permalink
fix(context-pad): fix scaling tests
Browse files Browse the repository at this point in the history
* scaling tests are now actually run
  • Loading branch information
barmac committed Oct 9, 2018
1 parent 12b6ea1 commit a9708db
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions test/spec/features/context-pad/ContextPadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];

Expand All @@ -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',
Expand Down Expand Up @@ -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);
});

});
Expand Down

0 comments on commit a9708db

Please sign in to comment.