Adds tests about flip methods

This commit is contained in:
Nelson Campos 2018-04-17 16:23:21 +01:00
parent 43d3949dd1
commit a31587df2f
2 changed files with 39 additions and 3 deletions

View File

@ -881,7 +881,6 @@ $.Viewport.prototype = {
if (!this.viewer || !this.viewer.drawer.canRotate()) { if (!this.viewer || !this.viewer.drawer.canRotate()) {
return this; return this;
} }
this.degrees = $.positiveModulo(degrees, 360); this.degrees = $.positiveModulo(degrees, 360);
this._setContentBounds( this._setContentBounds(
this.viewer.world.getHomeBounds(), this.viewer.world.getHomeBounds(),
@ -1531,7 +1530,6 @@ $.Viewport.prototype = {
return this; return this;
}, },
/** /**
* Gets flip state stored on viewport. * Gets flip state stored on viewport.
* @function * @function
@ -1541,7 +1539,6 @@ $.Viewport.prototype = {
return this.flipped; return this.flipped;
}, },
/** /**
* Sets flip state according to the state input argument. * Sets flip state according to the state input argument.
* @function * @function

View File

@ -1140,4 +1140,43 @@
}); });
}); });
QUnit.test('toggleFlipState', function(assert) {
var done = assert.async();
var openHandler = function(event) {
viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport;
assert.deepEqual(viewport.getFlip(), false, "Get original flip state should be false");
viewport.toggleFlip();
assert.deepEqual(viewport.getFlip(), true, "Toggling flip state variable, viewport should be true");
viewport.toggleFlip();
assert.deepEqual(viewport.getFlip(), false, "Toggling back flip state variable, viewport should be false again");
done();
};
viewer.addHandler('open', openHandler);
viewer.open(DZI_PATH);
});
QUnit.test('setFlipState', function(assert) {
var done = assert.async();
var openHandler = function(event) {
viewer.removeHandler('open', openHandler);
var viewport = viewer.viewport;
assert.deepEqual(viewport.getFlip(), false, "Get original flip state should be false");
viewport.setFlip(true);
assert.deepEqual(viewport.getFlip(), true, "Setting flip state variable should be true");
viewport.setFlip(false);
assert.deepEqual(viewport.getFlip(), false, "Unsetting flip state variable, viewport should be false again");
done();
};
viewer.addHandler('open', openHandler);
viewer.open(DZI_PATH);
});
})(); })();