@@ -2,7 +2,7 @@ import { setImmediate } from "timers/promises";
22import { BindingsPlugin , ScheduledEvent } from "@miniflare/core" ;
33import {
44 CronScheduler ,
5- Scheduler ,
5+ CronSchedulerImpl ,
66 SchedulerPlugin ,
77 startScheduler ,
88} from "@miniflare/scheduler" ;
@@ -14,10 +14,10 @@ import { Cron, ITimerHandle } from "cron-schedule";
1414// Waiting for CRONs is slow, so mock out a scheduler with manual dispatch
1515function createCronScheduler ( ) : [
1616 dispatch : ( cron : string ) => Promise < void > ,
17- scheduler : Promise < CronScheduler >
17+ scheduler : Promise < CronSchedulerImpl >
1818] {
1919 const crons = new Map < string , Set < ( ) => Awaitable < void > > > ( ) ;
20- const scheduler : CronScheduler = {
20+ const scheduler : CronSchedulerImpl = {
2121 setInterval ( cron : Cron , task : ( ) => Awaitable < void > ) : ITimerHandle {
2222 const spec = cron . toString ( ) ;
2323 const set = crons . get ( spec ) ?? new Set ( ) ;
@@ -37,7 +37,7 @@ function createCronScheduler(): [
3737 return [ dispatch , Promise . resolve ( scheduler ) ] ;
3838}
3939
40- test ( "Scheduler : schedules tasks for validated CRONs on reload" , async ( t ) => {
40+ test ( "CronScheduler : schedules tasks for validated CRONs on reload" , async ( t ) => {
4141 let events : ScheduledEvent [ ] = [ ] ;
4242 const log = new TestLog ( ) ;
4343 const mf = useMiniflare (
@@ -51,7 +51,7 @@ test("Scheduler: schedules tasks for validated CRONs on reload", async (t) => {
5151 ) ;
5252 await mf . getPlugins ( ) ; // Wait for initial reload
5353 const [ dispatch , cronScheduler ] = createCronScheduler ( ) ;
54- new Scheduler ( mf , cronScheduler ) ;
54+ new CronScheduler ( mf , cronScheduler ) ;
5555 await setImmediate ( ) ;
5656
5757 // Check scheduler requires reload to schedule tasks
@@ -73,7 +73,7 @@ test("Scheduler: schedules tasks for validated CRONs on reload", async (t) => {
7373 t . is ( events [ 0 ] . cron , "30 * * * *" ) ;
7474 t . regex ( log . logs [ 0 ] [ 1 ] , / ^ S C H D 3 0 \* \* \* \* \( \d + \. \d + m s \) $ / ) ;
7575} ) ;
76- test ( "Scheduler : destroys tasks when CRONs change" , async ( t ) => {
76+ test ( "CronScheduler : destroys tasks when CRONs change" , async ( t ) => {
7777 const events : ScheduledEvent [ ] = [ ] ;
7878 // noinspection JSUnusedGlobalSymbols
7979 const options = {
@@ -84,7 +84,7 @@ test("Scheduler: destroys tasks when CRONs change", async (t) => {
8484 const mf = useMiniflare ( { SchedulerPlugin, BindingsPlugin } , options ) ;
8585 await mf . getPlugins ( ) ; // Wait for initial reload
8686 const [ dispatch , cronScheduler ] = createCronScheduler ( ) ;
87- new Scheduler ( mf , cronScheduler ) ;
87+ new CronScheduler ( mf , cronScheduler ) ;
8888 await mf . reload ( ) ; // Schedule tasks
8989
9090 t . is ( events . length , 0 ) ;
@@ -99,7 +99,7 @@ test("Scheduler: destroys tasks when CRONs change", async (t) => {
9999 t . is ( events . length , 2 ) ;
100100} ) ;
101101
102- test ( "Scheduler : dispose: destroys tasks and removes reload listener" , async ( t ) => {
102+ test ( "CronScheduler : dispose: destroys tasks and removes reload listener" , async ( t ) => {
103103 const events : ScheduledEvent [ ] = [ ] ;
104104 const mf = useMiniflare (
105105 { SchedulerPlugin, BindingsPlugin } ,
@@ -111,7 +111,7 @@ test("Scheduler: dispose: destroys tasks and removes reload listener", async (t)
111111 ) ;
112112 await mf . getPlugins ( ) ; // Wait for initial reload
113113 const [ dispatch , cronScheduler ] = createCronScheduler ( ) ;
114- const scheduler = new Scheduler ( mf , cronScheduler ) ;
114+ const scheduler = new CronScheduler ( mf , cronScheduler ) ;
115115 await mf . reload ( ) ; // Schedule tasks
116116
117117 t . is ( events . length , 0 ) ;
0 commit comments