feat: add reusable jobqueue library
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
28
tests/RetentionScheduler.test.ts
Normal file
28
tests/RetentionScheduler.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { RetentionScheduler } from '../src/index.js';
|
||||
|
||||
describe('RetentionScheduler', () => {
|
||||
it('runs stale and delete handlers', async () => {
|
||||
const calls: string[] = [];
|
||||
const scheduler = new RetentionScheduler(
|
||||
{
|
||||
staleAfterMs: 1_000,
|
||||
deleteAfterMs: 2_000,
|
||||
},
|
||||
{
|
||||
markStale: async () => {
|
||||
calls.push('stale');
|
||||
return [];
|
||||
},
|
||||
deleteStale: async () => {
|
||||
calls.push('delete');
|
||||
return [];
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await scheduler.runCycle();
|
||||
scheduler.stop();
|
||||
|
||||
expect(calls).toEqual(['stale', 'delete']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user