Open History to see the last commit
1import { QueryClient } from "@tanstack/react-query";
2import { describe, expect, it } from "vitest";
3import {
4 gitMutationKeys,
5 gitPreparePullRequestThreadMutationOptions,
6 gitPullMutationOptions,
7 gitRunStackedActionMutationOptions,
8} from "./gitReactQuery";
9
10describe("gitMutationKeys", () => {
11 it("scopes stacked action keys by cwd", () => {
12 expect(gitMutationKeys.runStackedAction("/repo/a")).not.toEqual(
13 gitMutationKeys.runStackedAction("/repo/b"),
14 );
15 });
16
17 it("scopes pull keys by cwd", () => {
18 expect(gitMutationKeys.pull("/repo/a")).not.toEqual(gitMutationKeys.pull("/repo/b"));
19 });
20
21 it("scopes pull request thread preparation keys by cwd", () => {
22 expect(gitMutationKeys.preparePullRequestThread("/repo/a")).not.toEqual(
23 gitMutationKeys.preparePullRequestThread("/repo/b"),
24 );
25 });
26});
27
28describe("git mutation options", () => {
29 const queryClient = new QueryClient();
30
31 it("attaches cwd-scoped mutation key for runStackedAction", () => {
32 const options = gitRunStackedActionMutationOptions({
33 cwd: "/repo/a",
34 queryClient,
35 });
36 expect(options.mutationKey).toEqual(gitMutationKeys.runStackedAction("/repo/a"));
37 });
38
39 it("attaches cwd-scoped mutation key for pull", () => {
40 const options = gitPullMutationOptions({ cwd: "/repo/a", queryClient });
41 expect(options.mutationKey).toEqual(gitMutationKeys.pull("/repo/a"));
42 });
43
44 it("attaches cwd-scoped mutation key for preparePullRequestThread", () => {
45 const options = gitPreparePullRequestThreadMutationOptions({
46 cwd: "/repo/a",
47 queryClient,
48 });
49 expect(options.mutationKey).toEqual(gitMutationKeys.preparePullRequestThread("/repo/a"));
50 });
51});