Skip to content

Instantly share code, notes, and snippets.

@ZackMattor
Created July 7, 2016 19:57
Show Gist options
  • Save ZackMattor/fbbd8d266b109b09f828398490f1c326 to your computer and use it in GitHub Desktop.
Save ZackMattor/fbbd8d266b109b09f828398490f1c326 to your computer and use it in GitHub Desktop.
jquery jasmine analytics
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