Skip to content

Commit

Permalink
add unit tests for destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
podefr committed Jul 31, 2013
1 parent 95ec3f2 commit 664e8e9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions specs/LocationRouter.spec.js
Expand Up @@ -125,4 +125,33 @@ require(["LocationRouter", "Router"], function (LocationRouter, Router) {

});

describe("LocationRouter can be destroyed", function () {
var locationRouter = null;

beforeEach(function() {
locationRouter = new LocationRouter();
});

it("removes the watch handler", function () {
spyOn(locationRouter, "watch").andReturn(1337);
spyOn(locationRouter, "unwatch");

locationRouter.start();

locationRouter.destroy();

expect(locationRouter.unwatch).toHaveBeenCalledWith(1337);
});

it("removes the hashchange event listener", function () {
spyOn(window, "removeEventListener");

locationRouter.start();

locationRouter.destroy();

expect(window.removeEventListener).toHaveBeenCalledWith("hashchange", locationRouter.boundOnHashChange, true);
});
});

});

0 comments on commit 664e8e9

Please sign in to comment.