I know I can spy on the jQuery function, but instead, I chose to do
this (code is in coffeescript):
it 'should be revealed when "lightbox" is clicked', () ->
lightbox_button = $('li#lightbox-link a')
lightbox_button.click()
expect(@
lightbox_number.is(":visible")).toBe(true)
the behavior of the click is to do a
$('#lightbox-number').slideDown()
This kind of test makes sense from the perspective of what I "expect"
to happen but relies on the is(":visible") function returning true
immediately upon completion of the slideDown() function. Because
slideDown() is an animation, it's possible that there would be some
delay before the visibility changed. This would probably be more
pronounced in the case of slideUp() where the visibility changes at
the end of the animation instead of the start.
What are others doing to test things like this in a less brittle way
than I've chosen.
Thanks