Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.3 KB
Raw Blame
import { describe, expect, it } from "vite-plus/test";
import { parseInstallArgs } from "./index.js";

describe("parseInstallArgs", () => {
  it("parses flags", () => {
    // Arrange
    const argv = [
      "--target",
      "cursor-user",
      "--name",
      "my-kaneo",
      "-y",
      "--api-url",
      "http://example.com",
    ];
    const expected = {
      target: "cursor-user",
      output: undefined,
      name: "my-kaneo",
      yes: true,
      apiUrl: "http://example.com",
      projectDir: process.cwd(),
      help: false,
    };

    // Act
    const result = parseInstallArgs(argv);

    // Assert
    expect(result).toEqual(expected);
  });

  it("throws on unknown option", () => {
    // Arrange
    const argv = ["--nope"];
    // Act
    const act = () => parseInstallArgs(argv);

    // Assert
    expect(act).toThrow("Unknown option");
  });

  it("allows --target values that start with '-' when they are not flags", () => {
    // Arrange
    const argv = ["--target", "-my-server", "-y"];
    const expected = {
      target: "-my-server",
      output: undefined,
      name: "kaneo",
      yes: true,
      apiUrl: undefined,
      projectDir: process.cwd(),
      help: false,
    };

    // Act
    const result = parseInstallArgs(argv);

    // Assert
    expect(result).toEqual(expected);
  });
});