Created
February 21, 2014 01:52
-
-
Save vojtajina/9127352 to your computer and use it in GitHub Desktop.
Code example for Merrick.
This file contains hidden or 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
it('should call append', inject($, MyUI, function(jQuery, ui) { | |
spyOn(jQuery, 'append'); | |
ui.render(); | |
expect(jQuery.append).toHaveBeenCalled(); | |
}); |
This file contains hidden or 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
@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(); | |
}); |
This file contains hidden or 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
it('should mock append before instantiating', function() { | |
inject($, function(jQuery) { | |
spyOn(jQuery, 'append'); | |
}); | |
inject($, MyUI, function(jQuery, ui) { | |
ui.render(); | |
expect(jQuery.append).toHaveBeenCalled(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this gist. Very helpful. :-)