Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit 51c6579

Browse files
committed
test(event): Add test to ensure event handlers aren't duplicated.
#22
1 parent a665ed3 commit 51c6579

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/unit/events.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,28 @@ describe('custom events', () => {
4242
done();
4343
}, 1);
4444
});
45+
46+
it('should not duplicate handlers', done => {
47+
let count = 0;
48+
const Comp = reactify(document.registerElement('x-custom-event-3', {
49+
prototype: Object.create(HTMLElement.prototype, {
50+
trigger: {
51+
value() {
52+
this.dispatchEvent(new CustomEvent('test'));
53+
},
54+
},
55+
}),
56+
}), { React, ReactDOM });
57+
58+
const func = () => ++count;
59+
60+
// Using both ontest and onTest (case-sensitive) test case-sensitivity.
61+
const comp = ReactDOM.render(<Comp ontest={func} onTest={func} />, window.fixture);
62+
63+
setTimeout(() => {
64+
ReactDOM.findDOMNode(comp).trigger();
65+
expect(count).to.equal(1);
66+
done();
67+
}, 1);
68+
});
4569
});

0 commit comments

Comments
 (0)