@@ -186,32 +186,78 @@ describe("Mouse class", () => {
186186 expect ( releaseButtonMock ) . toBeCalledWith ( Button . LEFT ) ;
187187 expect ( result ) . toBe ( SUT ) ;
188188 } ) ;
189- } ) ;
190189
191- describe ( "Mousebuttons" , ( ) => {
192- it . each ( [
193- [ Button . LEFT , Button . LEFT ] ,
194- [ Button . MIDDLE , Button . MIDDLE ] ,
195- [ Button . RIGHT , Button . RIGHT ] ,
196- ] as Array < [ Button , Button ] > ) ( "should be pressed and released" , async ( input : Button , expected : Button ) => {
197- // GIVEN
198- const SUT = new MouseClass ( providerRegistryMock ) ;
199- const pressButtonMock = jest . fn ( ) ;
200- const releaseButtonMock = jest . fn ( ) ;
201- providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
202- setMouseDelay : jest . fn ( ) ,
203- pressButton : pressButtonMock ,
204- releaseButton : releaseButtonMock
205- } ) ) ;
206-
207- // WHEN
208- const pressed = await SUT . pressButton ( input ) ;
209- const released = await SUT . releaseButton ( input ) ;
210-
211- // THEN
212- expect ( pressButtonMock ) . toBeCalledWith ( expected ) ;
213- expect ( releaseButtonMock ) . toBeCalledWith ( expected ) ;
214- expect ( pressed ) . toBe ( SUT ) ;
215- expect ( released ) . toBe ( SUT ) ;
190+ describe ( "Mousebuttons" , ( ) => {
191+ it . each ( [
192+ [ Button . LEFT , Button . LEFT ] ,
193+ [ Button . MIDDLE , Button . MIDDLE ] ,
194+ [ Button . RIGHT , Button . RIGHT ] ,
195+ ] as Array < [ Button , Button ] > ) ( "should be pressed and released" , async ( input : Button , expected : Button ) => {
196+ // GIVEN
197+ const SUT = new MouseClass ( providerRegistryMock ) ;
198+ const pressButtonMock = jest . fn ( ) ;
199+ const releaseButtonMock = jest . fn ( ) ;
200+ providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
201+ setMouseDelay : jest . fn ( ) ,
202+ pressButton : pressButtonMock ,
203+ releaseButton : releaseButtonMock
204+ } ) ) ;
205+
206+ // WHEN
207+ const pressed = await SUT . pressButton ( input ) ;
208+ const released = await SUT . releaseButton ( input ) ;
209+
210+ // THEN
211+ expect ( pressButtonMock ) . toBeCalledWith ( expected ) ;
212+ expect ( releaseButtonMock ) . toBeCalledWith ( expected ) ;
213+ expect ( pressed ) . toBe ( SUT ) ;
214+ expect ( released ) . toBe ( SUT ) ;
215+ } ) ;
216216 } ) ;
217+
218+ describe ( "click and doubleClick" , ( ) => {
219+ describe ( "click" , ( ) => {
220+ it . each ( [
221+ [ Button . LEFT , Button . LEFT ] ,
222+ [ Button . MIDDLE , Button . MIDDLE ] ,
223+ [ Button . RIGHT , Button . RIGHT ] ,
224+ ] as Array < [ Button , Button ] > ) ( "should click the respective button on the provider" , async ( input : Button , expected : Button ) => {
225+ // GIVEN
226+ const SUT = new MouseClass ( providerRegistryMock ) ;
227+ const clickMock = jest . fn ( ) ;
228+ providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
229+ setMouseDelay : jest . fn ( ) ,
230+ click : clickMock ,
231+ } ) ) ;
232+
233+ // WHEN
234+ await SUT . click ( input ) ;
235+
236+ // THEN
237+ expect ( clickMock ) . toBeCalledWith ( expected ) ;
238+ } ) ;
239+ } ) ;
240+
241+ describe ( "doubleClick" , ( ) => {
242+ it . each ( [
243+ [ Button . LEFT , Button . LEFT ] ,
244+ [ Button . MIDDLE , Button . MIDDLE ] ,
245+ [ Button . RIGHT , Button . RIGHT ] ,
246+ ] as Array < [ Button , Button ] > ) ( "should click the respective button on the provider" , async ( input : Button , expected : Button ) => {
247+ // GIVEN
248+ const SUT = new MouseClass ( providerRegistryMock ) ;
249+ const clickMock = jest . fn ( ) ;
250+ providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
251+ setMouseDelay : jest . fn ( ) ,
252+ doubleClick : clickMock ,
253+ } ) ) ;
254+
255+ // WHEN
256+ await SUT . doubleClick ( input ) ;
257+
258+ // THEN
259+ expect ( clickMock ) . toBeCalledWith ( expected ) ;
260+ } ) ;
261+ } ) ;
262+ } )
217263} ) ;
0 commit comments