chore: 添加 .oxfmtrc.json 并格式化全部代码
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { describe, it, expect } from "bun:test";
|
||||
import { formatError } from "../../src/cli/output.ts";
|
||||
import {
|
||||
UsageError,
|
||||
ConfigError,
|
||||
CommandError,
|
||||
InternalError,
|
||||
} from "../../src/cli/errors.ts";
|
||||
import { UsageError, ConfigError, CommandError, InternalError } from "../../src/cli/errors.ts";
|
||||
|
||||
describe("formatError", () => {
|
||||
it("只输出错误行(无 hint/usage)", () => {
|
||||
@@ -25,15 +20,13 @@ describe("formatError", () => {
|
||||
usage: "rune plan <change-name>",
|
||||
});
|
||||
const output = formatError(err);
|
||||
expect(output).toBe(
|
||||
"错误: 缺少参数\n\n用法: rune plan <change-name>",
|
||||
);
|
||||
expect(output).toBe("错误: 缺少参数\n\n用法: rune plan <change-name>");
|
||||
});
|
||||
|
||||
it("输出完整格式(错误 + 用法 + 提示)", () => {
|
||||
const err = new UsageError("缺少必填参数 <change-name>", {
|
||||
usage: "rune plan <change-name>",
|
||||
hint: "请指定变更名称,如 \"add-login\"",
|
||||
hint: '请指定变更名称,如 "add-login"',
|
||||
});
|
||||
const output = formatError(err);
|
||||
expect(output).toBe(
|
||||
|
||||
@@ -33,9 +33,7 @@ describe("formatChangeStatus", () => {
|
||||
|
||||
it("显示文档依赖信息(dependMet 为 false 且 config 中有依赖)", () => {
|
||||
const status = makeStatus({
|
||||
documents: [
|
||||
{ name: "task", completed: false, dependMet: false },
|
||||
],
|
||||
documents: [{ name: "task", completed: false, dependMet: false }],
|
||||
});
|
||||
const config: RuneConfig = {
|
||||
stages: {
|
||||
@@ -53,9 +51,7 @@ describe("formatChangeStatus", () => {
|
||||
|
||||
it("dependMet 为 false 但无 config 时不显示文档依赖信息", () => {
|
||||
const status = makeStatus({
|
||||
documents: [
|
||||
{ name: "task", completed: false, dependMet: false },
|
||||
],
|
||||
documents: [{ name: "task", completed: false, dependMet: false }],
|
||||
});
|
||||
const output = formatChangeStatus(status);
|
||||
expect(output).not.toContain("(依赖");
|
||||
@@ -102,18 +98,14 @@ describe("formatChangeStatus", () => {
|
||||
describe("suggestNextStep", () => {
|
||||
it("规划未完成时返回下一个可规划文档", () => {
|
||||
const status = makeStatus({
|
||||
documents: [
|
||||
{ name: "design", completed: false, dependMet: true },
|
||||
],
|
||||
documents: [{ name: "design", completed: false, dependMet: true }],
|
||||
});
|
||||
expect(suggestNextStep(status)).toContain("rune plan test-change design");
|
||||
});
|
||||
|
||||
it("规划未完成且依赖未满足时提示完成前置依赖", () => {
|
||||
const status = makeStatus({
|
||||
documents: [
|
||||
{ name: "design", completed: false, dependMet: false },
|
||||
],
|
||||
documents: [{ name: "design", completed: false, dependMet: false }],
|
||||
});
|
||||
expect(suggestNextStep(status)).toBe("完成前置依赖后再规划文档");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user