Skip to content

Instantly share code, notes, and snippets.

@quard8
Created June 7, 2014 19:35
Show Gist options
  • Save quard8/75b20fc22866a48524ef to your computer and use it in GitHub Desktop.
Save quard8/75b20fc22866a48524ef to your computer and use it in GitHub Desktop.
Simple check if Image created and setup properly with Jest and Jasmine
describe('simple test', function() {
var obj = {
create_image: function() {
var image = new Image();
image.src = 'http://google.com/1x1.gif';
}
}
it('should create image', function() {
var old_image = global.Image,
image_src = '';
var image = function() {
this.src = '';
};
Object.defineProperty(image.prototype, "src", {
set: function(src) {
image_src = src;
}
});
global.Image = image;
obj.create_image();
expect(image_src).toEqual('http://google.com/1x1.gif');
global.Image = old_image;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment