mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-11 03:37:57 +00:00
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import type { GitHubIssue } from "./github.ts";
|
|
import { analyzeIssue, parseIssueBody } from "./issue-triage-lib.ts";
|
|
|
|
function assertEquals(actual: unknown, expected: unknown) {
|
|
const actualJson = JSON.stringify(actual);
|
|
const expectedJson = JSON.stringify(expected);
|
|
|
|
if (actualJson !== expectedJson) {
|
|
throw new Error(`Expected ${expectedJson}, received ${actualJson}`);
|
|
}
|
|
}
|
|
|
|
function featureIssue(body: string): GitHubIssue {
|
|
return {
|
|
number: 1,
|
|
title: "[Feature] Improve issue triage",
|
|
body,
|
|
state: "open",
|
|
labels: [{ name: "enhancement" }],
|
|
comments: 0,
|
|
created_at: "2026-10-01T00:00:00Z",
|
|
updated_at: "2026-10-01T00:00:00Z",
|
|
user: { login: "contributor" },
|
|
html_url: "https://github.com/iflytek/skillhub/issues/1",
|
|
};
|
|
}
|
|
|
|
Deno.test("level-2 headings satisfy required feature sections", () => {
|
|
const result = analyzeIssue(
|
|
featureIssue(`## Problem
|
|
Filled issues are marked as incomplete.
|
|
|
|
## Proposed solution
|
|
Recognize level-2 headings during triage.`),
|
|
[],
|
|
new Date("2026-10-01T00:00:00Z"),
|
|
);
|
|
|
|
assertEquals(result.missingFields, []);
|
|
assertEquals(result.route === "needs-info", false);
|
|
});
|
|
|
|
Deno.test("level-3 Issue Form headings keep their existing behavior", () => {
|
|
const parsed = parseIssueBody(`### Problem
|
|
Filled issues are marked as incomplete.
|
|
|
|
### Proposed Solution
|
|
Recognize headings generated by Issue Forms.`);
|
|
|
|
assertEquals(parsed.sections, {
|
|
problem: "Filled issues are marked as incomplete.",
|
|
"proposed solution": "Recognize headings generated by Issue Forms.",
|
|
});
|
|
});
|
|
|
|
Deno.test("mixed level-2 and level-3 headings are parsed together", () => {
|
|
const parsed = parseIssueBody(`## Problem
|
|
Filled issues are marked as incomplete.
|
|
|
|
### Proposed Solution
|
|
Recognize both supported heading levels.`);
|
|
|
|
assertEquals(parsed.sections, {
|
|
problem: "Filled issues are marked as incomplete.",
|
|
"proposed solution": "Recognize both supported heading levels.",
|
|
});
|
|
});
|