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.2 KB
Raw Blame
import { QueryClient } from "@tanstack/react-query";
import { describe, expect, it } from "vite-plus/test";
import { invalidateRelationTaskProject } from "./invalidate-relation-task-project";

describe("invalidateRelationTaskProject", () => {
  it.each(["columns", "plannedTasks", "archivedTasks"])(
    "refreshes the parent in %s without invalidating unrelated boards",
    async (location) => {
      const client = new QueryClient();
      const parent = { id: "parent" };
      client.setQueryData(["tasks", "parent-project"], {
        columns: location === "columns" ? [{ tasks: [parent] }] : [],
        plannedTasks: location === "plannedTasks" ? [parent] : [],
        archivedTasks: location === "archivedTasks" ? [parent] : [],
      });
      client.setQueryData(["tasks", "unrelated-project"], {
        columns: [{ tasks: [{ id: "other" }] }],
      });
      await invalidateRelationTaskProject(client, "parent");
      expect(
        client.getQueryState(["tasks", "parent-project"])?.isInvalidated,
      ).toBe(true);
      expect(
        client.getQueryState(["tasks", "unrelated-project"])?.isInvalidated,
      ).toBe(false);
      client.clear();
    },
  );
});