Skip to content

Commit

Permalink
Adding NavigatorPlugin tests #22
Browse files Browse the repository at this point in the history
  • Loading branch information
danielalves committed Mar 10, 2015
1 parent 9bb0c40 commit 90952db
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions spec/javascripts/PluginNavigatorSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
describe("SilverTrack.Plugins.Navigator", function() {

var track = null;
var plugin = null;

Expand Down Expand Up @@ -28,6 +29,33 @@ describe("SilverTrack.Plugins.Navigator", function() {
});
});

describe("on uninstall", function() {

beforeEach(function() {
plugin.onUninstall(track);
});

it("remove click handlers", function() {
spyOn(plugin, "_handlePreviousPageClick");
spyOn(plugin, "_handleNextPageClick");

expect(plugin.prev).not.toBe(null);
expect(plugin.prev).not.toBe(null);

expect(plugin._handlePreviousPageClick).not.toHaveBeenCalled();
expect(plugin._handleNextPageClick).not.toHaveBeenCalled();
});

it("remove disabled class", function() {
expect(plugin.prev).not.toBe(null);
expect(plugin.prev).not.toBe(null);

expect(plugin.prev.hasClass(plugin.options.disabledClass)).toBe(false);
expect(plugin.next.hasClass(plugin.options.disabledClass)).toBe(false);
});

});

describe("when configuring the items", function() {
it("should bind track.prev() to prev item", function() {
spyOn(track, "prev");
Expand Down Expand Up @@ -111,4 +139,21 @@ describe("SilverTrack.Plugins.Navigator", function() {
});
});

describe("methods", function() {
describe("#goToNextPage", function() {
it("forwards call to track", function() {
spyOn(track, "next");
plugin.goToNextPage();
expect(track.next).toHaveBeenCalled();
});
});

describe("#goToPreviousPage", function() {
it("forwards call to track", function() {
spyOn(track, "prev");
plugin.goToPreviousPage();
expect(track.prev).toHaveBeenCalled();
});
});
});
});

0 comments on commit 90952db

Please sign in to comment.