44 clearCronScheduleCacheForTest ,
55 computeNextRunAtMs ,
66 computePreviousRunAtMs ,
7+ getCronScheduleCacheMaxForTest ,
78 getCronScheduleCacheSizeForTest ,
89 hasCronInCacheForTest ,
910} from "./schedule.js" ;
@@ -147,16 +148,17 @@ describe("cron schedule", () => {
147148
148149 it ( "promotes accessed entries to avoid premature LRU eviction" , ( ) => {
149150 const nowMs = Date . parse ( "2026-03-01T00:00:00.000Z" ) ;
151+ const cacheMax = getCronScheduleCacheMaxForTest ( ) ;
150152
151153 // Fill cache to capacity with unique expressions.
152154 // i=0 → "0 0 * * *", i=1 → "1 0 * * *", ..., i=511 → "31 8 * * *"
153- for ( let i = 0 ; i < 512 ; i ++ ) {
155+ for ( let i = 0 ; i < cacheMax ; i ++ ) {
154156 computeNextRunAtMs (
155157 { kind : "cron" , expr : `${ i % 60 } ${ Math . floor ( i / 60 ) } * * *` , tz : "UTC" } ,
156158 nowMs ,
157159 ) ;
158160 }
159- expect ( getCronScheduleCacheSizeForTest ( ) ) . toBe ( 512 ) ;
161+ expect ( getCronScheduleCacheSizeForTest ( ) ) . toBe ( cacheMax ) ;
160162
161163 // Entry #0 ("0 0 * * *") is the oldest by insertion order.
162164 // Access it so LRU promotes it (delete + re-insert at end of Map).
@@ -165,7 +167,7 @@ describe("cron schedule", () => {
165167 // Entry #1 ("1 0 * * *") is now the least-recently-used.
166168 // Insert a new entry to trigger one eviction.
167169 computeNextRunAtMs ( { kind : "cron" , expr : "0 0 1 1 *" , tz : "UTC" } , nowMs ) ;
168- expect ( getCronScheduleCacheSizeForTest ( ) ) . toBe ( 512 ) ;
170+ expect ( getCronScheduleCacheSizeForTest ( ) ) . toBe ( cacheMax ) ;
169171
170172 // Under LRU: entry #0 survived (was promoted), entry #1 was evicted.
171173 // Under FIFO: entry #0 would be evicted instead — this assertion would fail.
0 commit comments