@@ -149,4 +149,48 @@ describe("Keyboard", () => {
149149 // THEN
150150 expect ( keyMock ) . toHaveBeenCalledTimes ( payload . length ) ;
151151 } ) ;
152+
153+ describe ( "autoDelayMs" , ( ) => {
154+ it ( "pressKey should respect configured delay" , async ( ) => {
155+ // GIVEN
156+ const SUT = new KeyboardClass ( providerRegistryMock ) ;
157+ const delay = 100 ;
158+ SUT . config . autoDelayMs = delay ;
159+
160+ const keyMock = jest . fn ( ) ;
161+ providerRegistryMock . getKeyboard = jest . fn ( ( ) => mockPartial < KeyboardProviderInterface > ( {
162+ setKeyboardDelay : jest . fn ( ) ,
163+ pressKey : keyMock
164+ } ) ) ;
165+
166+ // WHEN
167+ const start = Date . now ( ) ;
168+ await SUT . pressKey ( Key . A ) ;
169+ const duration = Date . now ( ) - start ;
170+
171+ // THEN
172+ expect ( duration ) . toBeGreaterThanOrEqual ( delay ) ;
173+ } ) ;
174+
175+ it ( "should pass a list of input keys down to the releaseKey call." , async ( ) => {
176+ // GIVEN
177+ const SUT = new KeyboardClass ( providerRegistryMock ) ;
178+ const delay = 100 ;
179+ SUT . config . autoDelayMs = delay ;
180+
181+ const keyMock = jest . fn ( ) ;
182+ providerRegistryMock . getKeyboard = jest . fn ( ( ) => mockPartial < KeyboardProviderInterface > ( {
183+ setKeyboardDelay : jest . fn ( ) ,
184+ releaseKey : keyMock
185+ } ) ) ;
186+
187+ // WHEN
188+ const start = Date . now ( ) ;
189+ await SUT . releaseKey ( Key . A ) ;
190+ const duration = Date . now ( ) - start ;
191+
192+ // THEN
193+ expect ( duration ) . toBeGreaterThanOrEqual ( delay ) ;
194+ } ) ;
195+ } ) ;
152196} ) ;
0 commit comments