From a31587df2f9a694d0ad090249ee013b0155a1bbb Mon Sep 17 00:00:00 2001 From: Nelson Campos Date: Tue, 17 Apr 2018 16:23:21 +0100 Subject: [PATCH] Adds tests about flip methods --- src/viewport.js | 3 --- test/modules/viewport.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index a3e207b8..dec8513f 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -881,7 +881,6 @@ $.Viewport.prototype = { if (!this.viewer || !this.viewer.drawer.canRotate()) { return this; } - this.degrees = $.positiveModulo(degrees, 360); this._setContentBounds( this.viewer.world.getHomeBounds(), @@ -1531,7 +1530,6 @@ $.Viewport.prototype = { return this; }, - /** * Gets flip state stored on viewport. * @function @@ -1541,7 +1539,6 @@ $.Viewport.prototype = { return this.flipped; }, - /** * Sets flip state according to the state input argument. * @function diff --git a/test/modules/viewport.js b/test/modules/viewport.js index bebe7d77..abc1306f 100644 --- a/test/modules/viewport.js +++ b/test/modules/viewport.js @@ -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); + }); })();