Skip to content

Commit

Permalink
Remove focus from event capturing tests
Browse files Browse the repository at this point in the history
Using focus as a test event for capturing is failing in some browsers (I tested Edge & Chrome). Adding timeouts seemed to fix it, but instead of trying to workaround flakiness, I'm removing focus testing as it doesn't seem necessary for this test.
  • Loading branch information
andrewiggins committed Nov 22, 2023
1 parent d72d974 commit fd9f4a5
Showing 1 changed file with 5 additions and 11 deletions.
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

0 comments on commit fd9f4a5

Please sign in to comment.