26 lines
736 B
TypeScript
26 lines
736 B
TypeScript
import { mkdtemp, rm } from 'node:fs/promises';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
import { StateStore } from '../src/state/state.js';
|
|
|
|
let dir = '';
|
|
|
|
beforeEach(async () => {
|
|
dir = await mkdtemp(join(tmpdir(), 'nlc-'));
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await rm(dir, { force: true, recursive: true });
|
|
});
|
|
|
|
describe('state persistence', () => {
|
|
it('tracks processed messages incrementally', async () => {
|
|
const store = new StateStore(join(dir, 'state.json'));
|
|
|
|
expect(await store.isProcessed('msg-1')).toBe(false);
|
|
await store.markProcessed('msg-1');
|
|
expect(await store.isProcessed('msg-1')).toBe(true);
|
|
});
|
|
});
|