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 { getTaskLabelOptions } from "./get-task-label-options";

describe("getTaskLabelOptions", () => {
  it("excludes a pending workspace label and its remaining task copy", () => {
    const labels = [
      { id: "copy", name: "Bug", taskId: "task-1" },
      {
        id: "root",
        name: "Bug",
        taskId: null,
        deletionStartedAt: "2026-09-19T12:00:00Z",
      },
      { id: "other", name: "Ready", taskId: null },
    ];
    expect(
      getTaskLabelOptions(labels, "task-1").map((label) => label.id),
    ).toEqual(["other"]);
  });
  it("excludes labels assigned to other tasks", () => {
    const labels = [
      { id: "workspace", name: "Bug", taskId: null },
      { id: "current", name: "Imported", taskId: "task-1" },
      { id: "other", name: "Other", taskId: "task-2" },
    ];

    const options = getTaskLabelOptions(labels, "task-1");

    expect(options.map((label) => label.id)).toEqual(["workspace", "current"]);
  });

  it("prefers a workspace label over a task-scoped copy", () => {
    const labels = [
      { id: "task-copy", name: "Bug", taskId: "task-1" },
      { id: "workspace", name: "Bug", taskId: null },
    ];

    const options = getTaskLabelOptions(labels, "task-1");

    expect(options).toEqual([{ id: "workspace", name: "Bug", taskId: null }]);
  });
});