From 31d6a77af63feb211bcf5fc103b28eb755173fc4 Mon Sep 17 00:00:00 2001 From: Adam Halim Date: Fri, 10 Jan 2025 12:21:52 +0100 Subject: [PATCH] Check for correct button events in dragging tests Previously, these unit tests did not check which events were sent to the server, only how many events were sent. This commit adds checks to see that the expected button events are sent. --- tests/test.rfb.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 061aff30..7bd25e4e 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -690,6 +690,10 @@ describe('Remote Frame Buffer protocol client', function () { sendMouseButtonEvent(13, 9, false, 0, client); expect(RFB.messages.pointerEvent).to.have.been.calledTwice; + expect(RFB.messages.pointerEvent.firstCall).to.have.been.calledWith(client._sock, + 13, 9, 0x1); + expect(RFB.messages.pointerEvent.secondCall).to.have.been.calledWith(client._sock, + 13, 9, 0x0); }); it('should send button messages when release with small movement', function () { @@ -699,6 +703,10 @@ describe('Remote Frame Buffer protocol client', function () { sendMouseButtonEvent(15, 14, false, 0, client); expect(RFB.messages.pointerEvent).to.have.been.calledTwice; + expect(RFB.messages.pointerEvent.firstCall).to.have.been.calledWith(client._sock, + 15, 14, 0x1); + expect(RFB.messages.pointerEvent.secondCall).to.have.been.calledWith(client._sock, + 15, 14, 0x0); }); it('should not send button messages when in view only', function () { @@ -714,6 +722,8 @@ describe('Remote Frame Buffer protocol client', function () { client.dragViewport = false; sendMouseButtonEvent(13, 9, true, 0, client); expect(RFB.messages.pointerEvent).to.have.been.calledOnce; + expect(RFB.messages.pointerEvent.firstCall).to.have.been.calledWith(client._sock, + 13, 9, 0x1); }); it('should be initiate viewport dragging on sufficient movement', function () {