Created
March 15, 2012 01:42
-
-
Save johnkpaul/2041117 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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