@@ -107,42 +107,6 @@ describe("Mouse class", () => {
107107 expect ( result ) . toBe ( SUT ) ;
108108 } ) ;
109109
110- it ( "should forward leftClick to the provider" , async ( ) => {
111- // GIVEN
112- const SUT = new MouseClass ( providerRegistryMock ) ;
113-
114- const clickMock = jest . fn ( ) ;
115- providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
116- setMouseDelay : jest . fn ( ) ,
117- leftClick : clickMock
118- } ) ) ;
119-
120- // WHEN
121- const result = await SUT . leftClick ( ) ;
122-
123- // THEN
124- expect ( clickMock ) . toBeCalled ( ) ;
125- expect ( result ) . toBe ( SUT ) ;
126- } ) ;
127-
128- it ( "should forward rightClick to the provider" , async ( ) => {
129- // GIVEN
130- const SUT = new MouseClass ( providerRegistryMock ) ;
131-
132- const clickMock = jest . fn ( ) ;
133- providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
134- setMouseDelay : jest . fn ( ) ,
135- rightClick : clickMock
136- } ) ) ;
137-
138- // WHEN
139- const result = await SUT . rightClick ( ) ;
140-
141- // THEN
142- expect ( clickMock ) . toBeCalled ( ) ;
143- expect ( result ) . toBe ( SUT ) ;
144- } ) ;
145-
146110 it ( "update mouse position along path on move" , async ( ) => {
147111 // GIVEN
148112 const SUT = new MouseClass ( providerRegistryMock ) ;
@@ -259,5 +223,49 @@ describe("Mouse class", () => {
259223 expect ( clickMock ) . toBeCalledWith ( expected ) ;
260224 } ) ;
261225 } ) ;
262- } )
226+
227+ describe ( "leftClick" , ( ) => {
228+ it ( "should use click internally" , async ( ) => {
229+ // GIVEN
230+ const SUT = new MouseClass ( providerRegistryMock ) ;
231+
232+ const clickSpy = jest . spyOn ( SUT , "click" ) ;
233+ const clickMock = jest . fn ( ) ;
234+ providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
235+ setMouseDelay : jest . fn ( ) ,
236+ click : clickMock
237+ } ) ) ;
238+
239+ // WHEN
240+ const result = await SUT . leftClick ( ) ;
241+
242+ // THEN
243+ expect ( clickSpy ) . toBeCalledWith ( Button . LEFT ) ;
244+ expect ( clickMock ) . toBeCalledWith ( Button . LEFT ) ;
245+ expect ( result ) . toBe ( SUT ) ;
246+ } ) ;
247+ } ) ;
248+
249+ describe ( "rightClick" , ( ) => {
250+ it ( "should use click internally" , async ( ) => {
251+ // GIVEN
252+ const SUT = new MouseClass ( providerRegistryMock ) ;
253+
254+ const clickSpy = jest . spyOn ( SUT , "click" ) ;
255+ const clickMock = jest . fn ( ) ;
256+ providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
257+ setMouseDelay : jest . fn ( ) ,
258+ click : clickMock
259+ } ) ) ;
260+
261+ // WHEN
262+ const result = await SUT . rightClick ( ) ;
263+
264+ // THEN
265+ expect ( clickSpy ) . toBeCalledWith ( Button . RIGHT ) ;
266+ expect ( clickMock ) . toBeCalledWith ( Button . RIGHT ) ;
267+ expect ( result ) . toBe ( SUT ) ;
268+ } ) ;
269+ } ) ;
270+ } ) ;
263271} ) ;
0 commit comments