Skip to content

Commit

Permalink
Add test for _move() internal method
Browse files Browse the repository at this point in the history
  • Loading branch information
i-like-robots committed Nov 3, 2013
1 parent c52ee0c commit e750d19
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/spec/easyzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,49 @@

});

asyncTest("_move(e)", function() {

expect(4);

var offset = api.$target.position();

var mock_1 = {
type: "mousemove",
pageX: offset.left + 10,
pageY: offset.top + 10
};

var mock_2 = {
type: "mousemove",
pageX: offset.left + 100,
pageY: offset.top + 100
}

// Must open the flyout with a zoom image first
api.opts.onShow = function() {
var left, top;

api._move(mock_1);

left = parseInt(api.$zoom.css("left"), 10);
top = parseInt(api.$zoom.css("top"), 10);

equal(left, -20, "2x scale zoom image moved 20px left given 10px offset");
equal(top, -20, "2x scale zoom image moved 20px top given 10px offset");

api._move(mock_2);

left = parseInt(api.$zoom.css("left"), 10);
top = parseInt(api.$zoom.css("top"), 10);

equal(left, -200, "2x scale zoom image moved 200px left given 100px offset");
equal(top, -200, "2x scale zoom image moved 200px top given 100px offset");

start();
};

api.show();

});

})();

0 comments on commit e750d19

Please sign in to comment.