@@ -177,6 +177,50 @@ describe("Mouse class", () => {
177177 expect ( pressed ) . toBe ( SUT ) ;
178178 expect ( released ) . toBe ( SUT ) ;
179179 } ) ;
180+
181+ describe ( "autoDelayMs" , ( ) => {
182+ it ( "pressButton should respect configured delay" , async ( ) => {
183+ // GIVEN
184+ const SUT = new MouseClass ( providerRegistryMock ) ;
185+ const delay = 100 ;
186+ SUT . config . autoDelayMs = delay ;
187+
188+ const mouseMock = jest . fn ( ) ;
189+ providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
190+ setMouseDelay : jest . fn ( ) ,
191+ pressButton : mouseMock
192+ } ) ) ;
193+
194+ // WHEN
195+ const start = Date . now ( ) ;
196+ await SUT . pressButton ( Button . LEFT ) ;
197+ const duration = Date . now ( ) - start ;
198+
199+ // THEN
200+ expect ( duration ) . toBeGreaterThanOrEqual ( delay ) ;
201+ } ) ;
202+
203+ it ( "releaseButton should respect configured delay" , async ( ) => {
204+ // GIVEN
205+ const SUT = new MouseClass ( providerRegistryMock ) ;
206+ const delay = 100 ;
207+ SUT . config . autoDelayMs = delay ;
208+
209+ const mouseMock = jest . fn ( ) ;
210+ providerRegistryMock . getMouse = jest . fn ( ( ) => mockPartial < MouseProviderInterface > ( {
211+ setMouseDelay : jest . fn ( ) ,
212+ releaseButton : mouseMock
213+ } ) ) ;
214+
215+ // WHEN
216+ const start = Date . now ( ) ;
217+ await SUT . releaseButton ( Button . LEFT ) ;
218+ const duration = Date . now ( ) - start ;
219+
220+ // THEN
221+ expect ( duration ) . toBeGreaterThanOrEqual ( delay ) ;
222+ } ) ;
223+ } ) ;
180224 } ) ;
181225
182226 describe ( "click and doubleClick" , ( ) => {
0 commit comments