Simulate Mouse Clicks in QUnit on Coordinates

I made a small plugin for jQuery to get the color of an image pixel. It's called broilerjs. I wanted to test the plugin via QUnit, a JavaScript Unit Testing framework. But I could not find a possibility to simulate a mouse click on special x and y coordinates. But in the end it was very easy.

Trigger the click event

I just have to build the click event manuall.
function simulateMouseClick(x, y) {
    var event = $.Event("click");
    event.clientX = x;
    event.clientY = y;
    $(document.elementFromPoint(x, y)).trigger(event);
}
Next Previous