diff --git a/test/browser/events.test.js b/test/browser/events.test.js index 666f107626..621e99c26e 100644 --- a/test/browser/events.test.js +++ b/test/browser/events.test.js @@ -4,6 +4,7 @@ import { teardown, supportsPassiveEvents } from '../_util/helpers'; +import { vi } from 'vitest'; /** @jsx createElement */ @@ -21,15 +22,15 @@ describe('event handling', () => { proto = document.createElement('div').constructor.prototype; - sinon.spy(proto, 'addEventListener'); - sinon.spy(proto, 'removeEventListener'); + vi.spyOn(proto, 'addEventListener'); + vi.spyOn(proto, 'removeEventListener'); }); afterEach(() => { teardown(scratch); - proto.addEventListener.restore(); - proto.removeEventListener.restore(); + proto.addEventListener.mockRestore(); + proto.removeEventListener.mockRestore(); }); it('should only register on* functions as handlers', () => { @@ -40,11 +41,10 @@ describe('event handling', () => { expect(scratch.childNodes[0].attributes.length).to.equal(0); - expect( - proto.addEventListener - ).to.have.been.calledOnce.and.to.have.been.calledWithExactly( + expect(proto.addEventListener).toHaveBeenCalledOnce(); + expect(proto.addEventListener).toHaveBeenCalledWith( 'click', - sinon.match.func, + expect.any(Function), false ); }); @@ -55,99 +55,131 @@ describe('event handling', () => { render(
, scratch); - expect( - proto.addEventListener - ).to.have.been.calledOnce.and.to.have.been.calledWithExactly( + expect(proto.addEventListener).toHaveBeenCalledOnce(); + expect(proto.addEventListener).toHaveBeenCalledWith( 'otherclick', - sinon.match.func, + expect.any(Function), false ); - expect(proto.addEventListener).not.to.have.been.calledWith('Click'); - expect(proto.addEventListener).not.to.have.been.calledWith('click'); + expect(proto.addEventListener).not.toHaveBeenCalledWith( + 'Click', + expect.anything(), + expect.anything() + ); + expect(proto.addEventListener).not.toHaveBeenCalledWith( + 'click', + expect.anything(), + expect.anything() + ); }); it('should support native event names', () => { - let click = sinon.spy(), - mousedown = sinon.spy(); + let click = vi.fn(), + mousedown = vi.fn(); render(hello
}cleanup}>hello {count}
}