Skip to content

Instantly share code, notes, and snippets.

@johnkpaul
Created March 15, 2012 01:42
Show Gist options
  • Save johnkpaul/2041117 to your computer and use it in GitHub Desktop.
Save johnkpaul/2041117 to your computer and use it in GitHub Desktop.
(function($,window, undefined){
module("sticky scroll unit tests",{
"setup":function(){
this.$el.get(0).getBoundingClientRect = function(){
return {left:100,top:100};
}
},
"setupSpies":function($el){
var plugin = this.getStickyScrollPlugin($el);
plugin.elementScrolledOff = sinon.spy();
plugin.elementScrolledOn = sinon.spy();
}
});
test("if element is scrolled off viewport, plugin elementScrolledOff method is called", function(){
this.$el.stickyScroll();
var plugin = this.getStickyScrollPlugin(this.$el);
this.setupSpies(this.$el);
var event = jQuery.Event("scroll");
event.target = $({scrollTop:101});
$(window).trigger(event);
equals(plugin.elementScrolledOff.called, true);
equals(plugin.elementScrolledOn.called, false);
});
})(window.jQuery,window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment