Skip to content

Commit 5523131

Browse files
committed
Merge use-state-subscription.spec.ts and use-run-no-subscription.spec.ts
1 parent 89bb878 commit 5523131

File tree

3 files changed

+52
-66
lines changed

3 files changed

+52
-66
lines changed

src/api/__tests__/use-run-no-subscription.spec.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/api/__tests__/use-state-subscription.spec.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { it, vi } from "vitest";
2+
import fc from "fast-check";
3+
4+
import type {
5+
CtrlStateQuery,
6+
CtrlStateSSubscription,
7+
CtrlRunNoQuery,
8+
CtrlRunNoSSubscription,
9+
} from "@/graphql/codegen/generated";
10+
11+
import { useSubscribeRunNo } from "../use-run-no-subscription";
12+
import { useSubscribeState } from "../use-state-subscription";
13+
14+
import { runPropertyTest } from "./run-property-test";
15+
16+
// Mock functions used in runPropertyTest()
17+
vi.mock("@urql/vue", () => ({
18+
useQuery: vi.fn(),
19+
useSubscription: vi.fn(),
20+
}));
21+
22+
it("useSubscribeState", async () => {
23+
type QueryData = CtrlStateQuery;
24+
type SubData = CtrlStateSSubscription;
25+
26+
const mapQuery = (d: QueryData | undefined) => d?.ctrl.state;
27+
const mapSub = (d: SubData | undefined) => d?.ctrlState;
28+
29+
const fcCtrlState = fc.string();
30+
const fcQueryData: fc.Arbitrary<QueryData> = fc.record({
31+
ctrl: fc.record({ state: fcCtrlState }),
32+
});
33+
const fcSubData: fc.Arbitrary<SubData> = fc.record({ ctrlState: fcCtrlState });
34+
35+
await runPropertyTest(useSubscribeState, mapQuery, mapSub, fcQueryData, fcSubData);
36+
});
37+
38+
it("useSubscribeRunNo", async () => {
39+
type QueryData = CtrlRunNoQuery;
40+
type SubData = CtrlRunNoSSubscription;
41+
42+
const mapQuery = (d: QueryData | undefined) => d?.ctrl.runNo;
43+
const mapSub = (d: SubData | undefined) => d?.ctrlRunNo;
44+
45+
const fcCtrlRunNo = fc.integer();
46+
const fcQueryData: fc.Arbitrary<QueryData> = fc.record({
47+
ctrl: fc.record({ runNo: fcCtrlRunNo }),
48+
});
49+
const fcSubData: fc.Arbitrary<SubData> = fc.record({ ctrlRunNo: fcCtrlRunNo });
50+
51+
await runPropertyTest(useSubscribeRunNo, mapQuery, mapSub, fcQueryData, fcSubData);
52+
});

0 commit comments

Comments
 (0)