Skip to content

Commit

Permalink
BulletNavigatorPlugin: now it supports uninstallation #22
Browse files Browse the repository at this point in the history
  • Loading branch information
danielalves committed Mar 9, 2015
1 parent 6d5ca40 commit 34cd307
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 20 additions & 1 deletion spec/javascripts/PluginBulletNavigatorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ describe("SilverTrack.Plugins.BulletNavigator", function() {
});
});

describe("on uninstall", function() {

beforeEach(function() {
plugin = new SilverTrack.Plugins.BulletNavigator({
container: $(".bullet-pagination", track.container.parent())
});

track.install(plugin);
track.start();
});

it("should remove all created bullets", function() {
plugin.onUninstall();
var bullets = getBullets(plugin, track);
expect(bullets.length).toBe(0);
});

});

describe("bullet creation", function() {
var bullets = null;

Expand Down Expand Up @@ -168,7 +187,7 @@ describe("SilverTrack.Plugins.BulletNavigator", function() {
expect(plugin._setupBulletClick).toHaveBeenCalled();
});

it("should able bullet click", function() {
it("should set activeClass correctly", function() {
var bullet1 = $(bullets[0]);
var bullet2 = $(bullets[1]);

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/jquery.silver_track.bullet_navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
this.track = track;
},

onUninstall: function(track) {
this._clearBullets();
},

afterStart: function() {
this._createBullets();
this._getBulletByPage(1).addClass(this.options.activeClass);
Expand Down

0 comments on commit 34cd307

Please sign in to comment.