Created
February 20, 2012 04:17
-
-
Save raulb/1867822 to your computer and use it in GitHub Desktop.
Fadeout test with 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
// If we want to test Asynchronous events we should use waits or waitsFor | |
// To test a fadeOut effect, waits(num ms) could be ok, but is not too smart in my opinion | |
// more info: https://github.com/pivotal/jasmine/wiki/Asynchronous-specs | |
// What happens if we want to test if any element is correctly deleted but before of that the element is going into a fadeOut | |
// event?. Which is happening is its opacity is going to 0 but immediately of that the element is undefined. | |
// This is my way to do it: | |
it("If one element is deleted correctly", function() { | |
loadFixtures("fixtureContent.html"); | |
expect($('#elements li').size()).toEqual(1); | |
$('#removeElement').click(); | |
// Wait for fadeOut event finished | |
waitsFor(function() { | |
return (($('#elementToRemove').css('opacity') == 0) || $('#elementToRemove').css('opacity') == undefined); | |
}, "The element won't ever be hidden", 10000); | |
runs(function () { | |
expect($('#elements li').size()).toEqual(0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks