Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions test/browser/events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,23 @@ describe('event handling', () => {
// Skip test if browser doesn't support passive events
if (supportsPassiveEvents()) {
it('should use capturing for event props ending with *Capture', () => {
let click = sinon.spy(),
focus = sinon.spy();
let click = sinon.spy();

render(
<div onClickCapture={click} onFocusCapture={focus}>
<button />
<div onClickCapture={click}>
<button type="button">Click me</button>
</div>,
scratch
);

let root = scratch.firstChild;
root.firstElementChild.click();
root.firstElementChild.focus();
let btn = scratch.firstChild.firstElementChild;
btn.click();

expect(click, 'click').to.have.been.calledOnce;

// Focus delegation requires a 50b hack I'm not sure we want to incur
expect(focus, 'focus').to.have.been.calledOnce;

// IE doesn't set it
if (!/Edge/.test(navigator.userAgent)) {
expect(click).to.have.been.calledWithMatch({ eventPhase: 0 }); // capturing
expect(focus).to.have.been.calledWithMatch({ eventPhase: 0 }); // capturing
}
});

Expand Down