Hello I got a question regarding unit testing with Jasmine (plugin: jQuery)
How could I test if the object is within the DOM of a document. The thing is that I use a tooltip function which will only be activated when an event is simulated. When there is a simulation of the effect, an object is attached to the DOM and I want to check if it is visible or not.
it("test 1: should invoke the Tooltip() function.", function () {
spyEvent = spyOnEvent('.span_width', "mouseover");
$('.span_width').simulate('mouseover');
expect('mouseover').toHaveBeenTriggeredOn('.span_width');
expect(spyEvent).toHaveBeenTriggered();
# A TEST TO check if .tooltip is visible???
# IN JQUERY would that be: $('.tooltip').is(':visible');
});
You commented IN JQUERY would that be: $('.tooltip').is(':visible');
Yes it would. In jasmine unit testing, so it passes the test, you're expecting the above to be true:
expect($('.tooltip').is(':visible')).toBe(true); // Passes
expect($('.tooltip').is(':visible')).toBe(false); // Fails