membLoper membLoper - 1 year ago 161
jQuery Question

Testing jQuery Hover with Jasmine

How should I go about testing a jQuery Hover action with Jasmine?
My jQuery looks like

function() { $('#someid').hide(); },
function() { $('#someid').show(); }

How could I simulate moving the hover action with jasmine and expect that 'someid' element is hidden and shown as it should?

Answer Source

You should be able to directly trigger a mouseover event and then test for the appropriate behavior:

it("should do something on hover", function() {

$('#someid') must be in the DOM. The best way to do that is through a fixture.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download