File size: 2,267 Bytes
9646e24 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { generateAnalysis } from "../analysis/generator";
describe("analysis generator", () => {
it("returns valid analysis on normal input (success path)", () => {
const analysis = generateAnalysis({
id: "test-1",
subject: "Test Subject",
sender: "sender@test.com",
receivedDate: new Date().toISOString(),
body: "This is a test email about pH levels and temperature readings.",
attachments: [],
} as any);
assert.ok(analysis, "analysis should be truthy");
assert.ok(analysis.wikitree, "wikitree should exist");
assert.ok(analysis.wikitree.root, "wikitree root should exist");
assert.ok(analysis.mindmap, "mindmap should exist");
assert.ok(analysis.mindmap.root, "mindmap root should exist");
assert.ok(analysis.execution, "execution should exist");
assert.ok(Array.isArray(analysis.execution.steps), "execution steps should be an array");
});
it("returns minimal valid analysis on empty input (edge case)", () => {
const analysis = generateAnalysis({
id: "test-2",
subject: "",
sender: "",
receivedDate: new Date().toISOString(),
body: "",
attachments: [],
} as any);
assert.ok(analysis, "should return analysis even on empty input");
assert.ok(analysis.wikitree?.root, "wikitree root should exist");
assert.ok(analysis.mindmap?.root, "mindmap root should exist");
assert.ok(analysis.execution, "execution should exist");
});
it("handles attachments with parsed data (success path)", () => {
const analysis = generateAnalysis({
id: "test-3",
subject: "Lab Results",
sender: "lab@test.com",
receivedDate: new Date().toISOString(),
body: "Spectroscopy results attached.",
attachments: [
{
name: "data.csv",
type: "csv",
parsedData: {
type: "csv",
rows: [{ site: "S1", ph: 7.6 }],
metadata: { rowCount: 1, headers: ["site", "ph"] },
},
},
],
} as any);
assert.ok(analysis, "should return analysis with attachments");
assert.ok(analysis.wikitree?.root, "wikitree should exist");
});
});
|