@@ -73,6 +73,9 @@ function createRuntimeHelpersMock(overrides: Partial<RuntimeHelpers> = {}): Runt
7373 now : mock ( ( ) => {
7474 throw new Error ( 'Method not implemented: now' )
7575 } ) ,
76+ sleep : mock ( ( ) => {
77+ throw new Error ( 'Method not implemented: sleep' )
78+ } ) ,
7679 log : mock ( ( ) => { } ) ,
7780 }
7881
@@ -357,6 +360,31 @@ describe('test now converts to date', () => {
357360 } )
358361} )
359362
363+ describe ( 'test sleep delegates to helpers' , ( ) => {
364+ test ( 'sleep calls helpers.sleep with the provided milliseconds' , ( ) => {
365+ const sleepMock = mock ( ( ) => { } )
366+ const helpers = createRuntimeHelpersMock ( {
367+ sleep : sleepMock ,
368+ } )
369+
370+ const runtime = new RuntimeImpl < unknown > ( { } , 1 , helpers , anyMaxSize )
371+ runtime . sleep ( 500 )
372+ expect ( sleepMock ) . toHaveBeenCalledTimes ( 1 )
373+ expect ( sleepMock ) . toHaveBeenCalledWith ( 500 )
374+ } )
375+
376+ test ( 'sleep passes zero milliseconds to helpers.sleep' , ( ) => {
377+ const sleepMock = mock ( ( ) => { } )
378+ const helpers = createRuntimeHelpersMock ( {
379+ sleep : sleepMock ,
380+ } )
381+
382+ const runtime = new RuntimeImpl < unknown > ( { } , 1 , helpers , anyMaxSize )
383+ runtime . sleep ( 0 )
384+ expect ( sleepMock ) . toHaveBeenCalledWith ( 0 )
385+ } )
386+ } )
387+
360388describe ( 'test getSecret' , ( ) => {
361389 test ( 'successfully gets secret with SecretRequest (proto message)' , ( ) => {
362390 const secretRequest = create ( SecretRequestSchema , {
0 commit comments