fix: comment updates and add a simple test for viewer.destroy

This commit is contained in:
Luke Murray 2013-08-12 16:38:37 +10:00
parent 68f9d675fc
commit 0c662b8a8d
4 changed files with 30 additions and 3 deletions

View File

@ -91,7 +91,8 @@ $.EventHandler.prototype = {
/**
* Remove all event handler for a given event type. If no type is given all event handlers for every event type is removed
* Remove all event handlers for a given event type. If no type is given all
* event handlers for every event type is removed.
* @function
* @param {String} eventName - Name of event for which all handlers are to be removed.
*/

View File

@ -172,7 +172,7 @@
$.MouseTracker.prototype = {
/**
* Clean up any events or objects created the mouse tracker
* Clean up any events or objects created by the mouse tracker.
* @function
*/
destroy: function() {

View File

@ -513,7 +513,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
/**
* Function to destroy the viewer and clean up everything created by Open Seadragon
* Function to destroy the viewer and clean up everything created by
* OpenSeadragon.
* @function
* @name OpenSeadragon.Viewer.prototype.destroy
*/

View File

@ -208,4 +208,29 @@
viewer.open('/test/data/testpattern.dzi');
});
// ----------
asyncTest('Destroy', function() {
viewer.addHandler("open", function () {
start();
// Check that the DOM has been modified
notEqual(0, $('#example').children().length);
var closeHandler = function() {
viewer.removeHandler('close', closeHandler);
ok(true, 'Close event was sent on Destroy');
};
viewer.addHandler('close', closeHandler);
viewer.destroy();
// Check that the DOM has been cleaned up
equal(0, $('#example').children().length);
equal(null, viewer.canvas);
equal(null, viewer.keyboardCommandArea);
equal(null, viewer.container);
equal(null, viewer.element);
});
viewer.open('/test/data/testpattern.dzi');
});
})();