45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
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 { runCatalog } from '../src/run/runCatalog.js';
|
|
|
|
let dir = '';
|
|
|
|
beforeEach(async () => {
|
|
dir = await mkdtemp(join(tmpdir(), 'nlc-run-'));
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await rm(dir, { force: true, recursive: true });
|
|
});
|
|
|
|
describe('run orchestration', () => {
|
|
it('does not write output or state during dry run', async () => {
|
|
const stateFile = join(dir, 'state.json');
|
|
const writes: unknown[] = [];
|
|
const result = await runCatalog({
|
|
dryRun: 1,
|
|
skipEnrich: true,
|
|
config: {
|
|
gmail: { folder: 'Newsletters' },
|
|
output: { name: 'Catalog', excel: { enabled: true, path: join(dir, 'out.xlsx') } },
|
|
stateFile
|
|
},
|
|
messages: [
|
|
{
|
|
id: 'msg-1',
|
|
messageId: '<msg-1>',
|
|
from: 'A <a@example.com>',
|
|
date: '2026-05-16T00:00:00.000Z',
|
|
html: '<h2>Python</h2><p><a href="https://example.com?utm_source=x">Article</a></p>'
|
|
}
|
|
],
|
|
writers: [{ write: async (payload) => writes.push(payload) }]
|
|
});
|
|
|
|
expect(result.linksExtracted).toBe(1);
|
|
expect(writes).toHaveLength(0);
|
|
});
|
|
});
|