65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { parseCommand } from "../src/cli.js";
|
|
|
|
describe("parseCommand", () => {
|
|
it("empty argv → command: help", () => {
|
|
expect(parseCommand([])).toEqual({ command: "help", args: {} });
|
|
});
|
|
|
|
it("unknown command → command: help", () => {
|
|
expect(parseCommand(["unknown"])).toEqual({ command: "help", args: {} });
|
|
});
|
|
|
|
it("init → command: init", () => {
|
|
const result = parseCommand(["init"]);
|
|
expect(result.command).toBe("init");
|
|
});
|
|
|
|
it("list → command: list", () => {
|
|
const result = parseCommand(["list"]);
|
|
expect(result.command).toBe("list");
|
|
});
|
|
|
|
it("add dialog → command: add, args.component: dialog", () => {
|
|
const result = parseCommand(["add", "dialog"]);
|
|
expect(result.command).toBe("add");
|
|
expect(result.args["component"]).toBe("dialog");
|
|
});
|
|
|
|
it("add dialog --dir src/ui → args.dir: src/ui", () => {
|
|
const result = parseCommand(["add", "dialog", "--dir", "src/ui"]);
|
|
expect(result.command).toBe("add");
|
|
expect(result.args["component"]).toBe("dialog");
|
|
expect(result.args["dir"]).toBe("src/ui");
|
|
});
|
|
|
|
it("inspect dialog → command: inspect, args.component: dialog", () => {
|
|
const result = parseCommand(["inspect", "dialog"]);
|
|
expect(result.command).toBe("inspect");
|
|
expect(result.args["component"]).toBe("dialog");
|
|
});
|
|
|
|
it("discover modal → command: discover, args.component: modal", () => {
|
|
const result = parseCommand(["discover", "modal"]);
|
|
expect(result.command).toBe("discover");
|
|
expect(result.args["component"]).toBe("modal");
|
|
});
|
|
|
|
it("help → command: help", () => {
|
|
const result = parseCommand(["help"]);
|
|
expect(result.command).toBe("help");
|
|
});
|
|
|
|
it("init --dir src/styles → args.dir: src/styles", () => {
|
|
const result = parseCommand(["init", "--dir", "src/styles"]);
|
|
expect(result.command).toBe("init");
|
|
expect(result.args["dir"]).toBe("src/styles");
|
|
});
|
|
|
|
it("--dir without value is ignored", () => {
|
|
const result = parseCommand(["list", "--dir"]);
|
|
expect(result.command).toBe("list");
|
|
expect(result.args["dir"]).toBeUndefined();
|
|
});
|
|
});
|