Created
July 7, 2016 19:57
-
-
Save ZackMattor/fbbd8d266b109b09f828398490f1c326 to your computer and use it in GitHub Desktop.
jquery jasmine analytics
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
var analytics = {}; | |
spyOn(instance, '$').and.callFake(function(selector) { | |
var jquery_proxy = $(selector); | |
['show', 'hide', 'scrollTop'].forEach(function(method) { | |
jquery_proxy[method] = jasmine.createSpy().and.callFake(function() { | |
analytics[selector] = analytics[selector] || {}; | |
if(typeof analytics[selector][method] === 'undefined') analytics[selector][method] = 0; | |
analytics[selector][method]++; | |
}); | |
}); | |
return jquery_proxy; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment