Created — forked from searls/some-source.js

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Add a little spy on creator that defaults to return this to support jQuery-like chaining.

View some-source.js
1 2 3
buttonifyAndHide = function($obj) {
$obj.button().hide();
};
View some-source.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
var $thing;
beforeEach(function(){
spyOnAndChain($.fn,'button');
 
$thing = $.jasmine.inject('<div></div>'); //See: https://github.com/searls/jasmine-fixture
buttonifyAndHide($thing);
});
 
it('calls button',function(){
expect($.fn.button).toHaveBeenCalled();
});
 
it('is hidden',function(){
expect($thing).not.toBeVisible();
});
View some-source.js
1 2 3 4 5 6 7 8
 
(function(){
window.spyOnAndChain = function(obj,method){
spyOn(obj,method).andCallFake(function(){
return this;
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.