Hi again,
I must be really dumb lol.
So, i test $.events
Right now,i only tested with the global syntax ( $.event(subject, handlers) )
describe("$.events", function() {
it('exists', function() {
expect($.events).to.exist;
});
describe("use with global", function() {
it("Set multiple event listeners on an element based on element", function(done) {
var subject = document.createElement("input");
subject.type = "text";
subject.id = "test";
document.body.appendChild(subject);
var clone = document.createElement("textarea");
clone.addEventListener("input", function(e){ done(); });
clone.addEventListener("click", function(e){ done(); });
$.events(subject, clone);
/* var ev = document.createEvent("MouseEvent");
ev.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
subject.dispatchEvent(ev);*/
subject.value = "test";
});
[...]
So the test is a success with the click event, but failed when i just change the value of the input.
If it was copying the events from the element, the test should pass with click event and input event.
The input event is implemented on both input and textarea. doc
I also tried with my own handler (not cloning from an other elements) and it didn't work at all.
it("Set multiple event listeners on an element", function(done) {
var subject = document.createElement("input");
subject.type = "text";
subject.id = "test";
document.body.appendChild(subject);
$.events(subject, {
'oninput onclick': function(e){ done(); }
});
var ev = document.createEvent("MouseEvent");
ev.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
subject.dispatchEvent(ev);
});
I don't know if i do things badly or i am just unlucky but i'm not really helping right now, i can't make a single test work :/
Sorry guys.