Created
June 7, 2014 19:35
-
-
Save quard8/75b20fc22866a48524ef to your computer and use it in GitHub Desktop.
Simple check if Image created and setup properly with Jest and Jasmine
This file contains 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
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