Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

gitReactQuery.test.ts

48 lines1.7 KB

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({ cwd: "/repo/a", queryClient });
33 expect(options.mutationKey).toEqual(gitMutationKeys.runStackedAction("/repo/a"));
34 });
35​
36 it("attaches cwd-scoped mutation key for pull", () => {
37 const options = gitPullMutationOptions({ cwd: "/repo/a", queryClient });
38 expect(options.mutationKey).toEqual(gitMutationKeys.pull("/repo/a"));
39 });
40​
41 it("attaches cwd-scoped mutation key for preparePullRequestThread", () => {
42 const options = gitPreparePullRequestThreadMutationOptions({
43 cwd: "/repo/a",
44 queryClient,
45 });
46 expect(options.mutationKey).toEqual(gitMutationKeys.preparePullRequestThread("/repo/a"));
47 });
48});