Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code example for Merrick.
it('should call append', inject($, MyUI, function(jQuery, ui) {
spyOn(jQuery, 'append');
ui.render();
expect(jQuery.append).toHaveBeenCalled();
});
@Provide($)
function jQueryMock() {
$.cleanAllState();
spyOn($, 'append');
spyOn($, 'html');
return $;
}
beforeEach(use(jQueryMock));
it('should use mock', inject($, MyUI, function(jQuery, ui) {
ui.render();
expect(jQuery.append).toHaveBeenCalled();
});
it('should mock append before instantiating', function() {
inject($, function(jQuery) {
spyOn(jQuery, 'append');
});
inject($, MyUI, function(jQuery, ui) {
ui.render();
expect(jQuery.append).toHaveBeenCalled();
});
});
@iammerrick

This comment has been minimized.

Copy link

@iammerrick iammerrick commented Feb 21, 2014

Thank you for this gist. Very helpful. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment