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.1 KB
Raw Blame
import { expect, it } from "vite-plus/test";
import type { ProjectWithTasks } from "@/types/project";
import { selectReorderBoard } from "./select-reorder-board";

it("includes a newly created local card without replacing newer cached metadata", () => {
  const cached = {
    id: "p",
    columns: [
      {
        slug: "todo",
        tasks: [{ id: "old", status: "todo", title: "new remote title" }],
      },
    ],
  } as unknown as ProjectWithTasks;
  const stored = {
    id: "p",
    columns: [
      {
        slug: "todo",
        tasks: [
          { id: "old", status: "todo", title: "stale title" },
          { id: "created", status: "todo", position: 1 },
        ],
      },
    ],
  } as unknown as ProjectWithTasks;
  expect(
    selectReorderBoard("p", "created", cached, stored)?.columns[0].tasks,
  ).toEqual([cached.columns[0].tasks[0], stored.columns[0].tasks[1]]);
  expect(
    selectReorderBoard("p", "old", cached, stored)?.columns[0].tasks,
  ).toEqual([cached.columns[0].tasks[0], stored.columns[0].tasks[1]]);
  expect(
    selectReorderBoard("p", "created", cached, { ...stored, id: "other" }),
  ).toBe(cached);
});