@jobber/hooks 2.0.3-pre1.55 → 2.0.3-pre2.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -7
- package/dist/index.js +10 -8
- package/dist/useAssert/index.d.ts +1 -1
- package/dist/useAssert/index.js +2 -2
- package/dist/useCollectionQuery/index.d.ts +1 -0
- package/dist/useCollectionQuery/index.js +5 -0
- package/dist/useCollectionQuery/mdxUtils.d.ts +53 -0
- package/dist/useCollectionQuery/mdxUtils.js +152 -0
- package/dist/useCollectionQuery/test-utilities/index.d.ts +3 -0
- package/dist/useCollectionQuery/test-utilities/index.js +19 -0
- package/dist/useCollectionQuery/test-utilities/mocks.d.ts +107 -0
- package/dist/useCollectionQuery/test-utilities/mocks.js +131 -0
- package/dist/useCollectionQuery/test-utilities/queries.d.ts +37 -0
- package/dist/useCollectionQuery/test-utilities/queries.js +59 -0
- package/dist/useCollectionQuery/test-utilities/utils.d.ts +1 -0
- package/dist/useCollectionQuery/test-utilities/utils.js +18 -0
- package/dist/useCollectionQuery/uniqueEdges.d.ts +8 -0
- package/dist/useCollectionQuery/uniqueEdges.js +19 -0
- package/dist/useCollectionQuery/uniqueNodes.d.ts +5 -0
- package/dist/useCollectionQuery/uniqueNodes.js +11 -0
- package/dist/useCollectionQuery/useCollectionQuery.d.ts +71 -0
- package/dist/useCollectionQuery/useCollectionQuery.js +181 -0
- package/dist/useCollectionQuery/useCollectionQuery.test.d.ts +1 -0
- package/dist/useCollectionQuery/useCollectionQuery.test.js +327 -0
- package/dist/useFocusTrap/index.d.ts +1 -1
- package/dist/useFocusTrap/index.js +2 -2
- package/dist/useFocusTrap/useFocusTrap.test.d.ts +1 -0
- package/dist/useFocusTrap/useFocusTrap.test.js +52 -0
- package/dist/useFormState/index.d.ts +1 -1
- package/dist/useFormState/index.js +2 -2
- package/dist/useIsMounted/index.d.ts +1 -1
- package/dist/useIsMounted/index.js +2 -2
- package/dist/useIsMounted/useIsMounted.test.js +3 -3
- package/dist/useLiveAnnounce/index.d.ts +1 -1
- package/dist/useLiveAnnounce/index.js +2 -2
- package/dist/useLiveAnnounce/useLiveAnnounce.test.js +2 -2
- package/dist/useOnKeyDown/index.d.ts +1 -0
- package/dist/useOnKeyDown/index.js +5 -0
- package/dist/useOnKeyDown/useOnKeyDown.d.ts +13 -0
- package/dist/useOnKeyDown/useOnKeyDown.js +33 -0
- package/dist/useOnKeyDown/useOnKeyDown.test.d.ts +1 -0
- package/dist/useOnKeyDown/useOnKeyDown.test.js +23 -0
- package/dist/usePasswordStrength/index.d.ts +1 -1
- package/dist/usePasswordStrength/index.js +2 -2
- package/dist/useRefocusOnActivator/index.d.ts +1 -1
- package/dist/useRefocusOnActivator/index.js +2 -2
- package/dist/useResizeObserver/index.d.ts +1 -0
- package/dist/useResizeObserver/index.js +17 -0
- package/dist/useResizeObserver/useResizeObserver.d.ts +19 -0
- package/dist/useResizeObserver/useResizeObserver.js +58 -0
- package/package.json +9 -9
- package/useAssert.d.ts +1 -0
- package/useAssert.js +17 -0
- package/useCollectionQuery.d.ts +1 -0
- package/useCollectionQuery.js +17 -0
- package/useFocusTrap.d.ts +1 -0
- package/useFocusTrap.js +17 -0
- package/useFormState.d.ts +1 -0
- package/useFormState.js +17 -0
- package/useIsMounted.d.ts +1 -0
- package/useIsMounted.js +17 -0
- package/useLiveAnnounce.d.ts +1 -0
- package/useLiveAnnounce.js +17 -0
- package/useOnKeyDown.d.ts +1 -0
- package/useOnKeyDown.js +17 -0
- package/usePasswordStrength.d.ts +1 -0
- package/usePasswordStrength.js +17 -0
- package/useRefocusOnActivator.d.ts +1 -0
- package/useRefocusOnActivator.js +17 -0
- package/useResizeObserver.d.ts +1 -0
- package/useResizeObserver.js +17 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export * from "./useAssert
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
1
|
+
export * from "./useAssert";
|
|
2
|
+
export * from "./useCollectionQuery";
|
|
3
|
+
export * from "./useFocusTrap";
|
|
4
|
+
export * from "./useFormState";
|
|
5
|
+
export * from "./useIsMounted";
|
|
6
|
+
export * from "./useLiveAnnounce";
|
|
7
|
+
export * from "./useOnKeyDown";
|
|
8
|
+
export * from "./usePasswordStrength";
|
|
9
|
+
export * from "./useRefocusOnActivator";
|
|
10
|
+
export * from "./useResizeObserver";
|
package/dist/index.js
CHANGED
|
@@ -14,11 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./useFocusTrap
|
|
20
|
-
__exportStar(require("./useFormState
|
|
21
|
-
__exportStar(require("./useIsMounted
|
|
22
|
-
__exportStar(require("./useLiveAnnounce
|
|
23
|
-
__exportStar(require("./
|
|
24
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./useAssert"), exports);
|
|
18
|
+
__exportStar(require("./useCollectionQuery"), exports);
|
|
19
|
+
__exportStar(require("./useFocusTrap"), exports);
|
|
20
|
+
__exportStar(require("./useFormState"), exports);
|
|
21
|
+
__exportStar(require("./useIsMounted"), exports);
|
|
22
|
+
__exportStar(require("./useLiveAnnounce"), exports);
|
|
23
|
+
__exportStar(require("./useOnKeyDown"), exports);
|
|
24
|
+
__exportStar(require("./usePasswordStrength"), exports);
|
|
25
|
+
__exportStar(require("./useRefocusOnActivator"), exports);
|
|
26
|
+
__exportStar(require("./useResizeObserver"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useAssert } from "./useAssert
|
|
1
|
+
export { useAssert } from "./useAssert";
|
package/dist/useAssert/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useAssert = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "useAssert", { enumerable: true, get: function () { return
|
|
4
|
+
var useAssert_1 = require("./useAssert");
|
|
5
|
+
Object.defineProperty(exports, "useAssert", { enumerable: true, get: function () { return useAssert_1.useAssert; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCollectionQuery } from "./useCollectionQuery";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCollectionQuery = void 0;
|
|
4
|
+
var useCollectionQuery_1 = require("./useCollectionQuery");
|
|
5
|
+
Object.defineProperty(exports, "useCollectionQuery", { enumerable: true, get: function () { return useCollectionQuery_1.useCollectionQuery; } });
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ApolloClient } from "@apollo/client";
|
|
2
|
+
export interface ListQueryType {
|
|
3
|
+
allPlanets: {
|
|
4
|
+
__typename?: "PlanetsConnection";
|
|
5
|
+
pageInfo: {
|
|
6
|
+
hasNextPage: boolean;
|
|
7
|
+
endCursor: string;
|
|
8
|
+
};
|
|
9
|
+
edges: Array<{
|
|
10
|
+
__typename?: "PlanetsEdge";
|
|
11
|
+
node: {
|
|
12
|
+
__typename?: "Planet";
|
|
13
|
+
name: "string";
|
|
14
|
+
id: "string";
|
|
15
|
+
};
|
|
16
|
+
cursor: string;
|
|
17
|
+
}>;
|
|
18
|
+
totalCount?: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare const LIST_QUERY: import("@apollo/client").DocumentNode;
|
|
22
|
+
export declare const apolloClient: ApolloClient<import("@apollo/client").NormalizedCacheObject>;
|
|
23
|
+
interface LoadingState {
|
|
24
|
+
loadingStatus: string;
|
|
25
|
+
loading: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function getLoadingState(loadingInitialContent: boolean, loadingRefresh: boolean, loadingNextPage: boolean): LoadingState;
|
|
28
|
+
export declare const propsList: ({
|
|
29
|
+
id: number;
|
|
30
|
+
title: string;
|
|
31
|
+
caption: string;
|
|
32
|
+
value: string;
|
|
33
|
+
url?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
id: number;
|
|
36
|
+
title: string;
|
|
37
|
+
caption: string;
|
|
38
|
+
url: string;
|
|
39
|
+
value: string;
|
|
40
|
+
})[];
|
|
41
|
+
export declare const subscriptionPropsList: {
|
|
42
|
+
id: number;
|
|
43
|
+
title: string;
|
|
44
|
+
caption: string;
|
|
45
|
+
value: string;
|
|
46
|
+
}[];
|
|
47
|
+
export declare const returnValues: {
|
|
48
|
+
id: number;
|
|
49
|
+
title: string;
|
|
50
|
+
caption: string;
|
|
51
|
+
value: string;
|
|
52
|
+
}[];
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.returnValues = exports.subscriptionPropsList = exports.propsList = exports.getLoadingState = exports.apolloClient = exports.LIST_QUERY = void 0;
|
|
4
|
+
const client_1 = require("@apollo/client");
|
|
5
|
+
exports.LIST_QUERY = (0, client_1.gql) `
|
|
6
|
+
query ListQuery($cursor: String) {
|
|
7
|
+
allPlanets(first: 4, after: $cursor) {
|
|
8
|
+
pageInfo {
|
|
9
|
+
hasNextPage
|
|
10
|
+
endCursor
|
|
11
|
+
}
|
|
12
|
+
edges {
|
|
13
|
+
node {
|
|
14
|
+
name
|
|
15
|
+
id
|
|
16
|
+
}
|
|
17
|
+
cursor
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
exports.apolloClient = new client_1.ApolloClient({
|
|
23
|
+
uri: "https://swapi-graphql.netlify.app/.netlify/functions/index",
|
|
24
|
+
cache: new client_1.InMemoryCache(),
|
|
25
|
+
});
|
|
26
|
+
function getLoadingState(loadingInitialContent, loadingRefresh, loadingNextPage) {
|
|
27
|
+
if (loadingInitialContent) {
|
|
28
|
+
return {
|
|
29
|
+
loading: true,
|
|
30
|
+
loadingStatus: "Initial Loading",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (loadingRefresh) {
|
|
34
|
+
return {
|
|
35
|
+
loading: true,
|
|
36
|
+
loadingStatus: "Refreshing",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (loadingNextPage) {
|
|
40
|
+
return {
|
|
41
|
+
loading: true,
|
|
42
|
+
loadingStatus: "Fetching More",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
loading: false,
|
|
47
|
+
loadingStatus: "Loaded",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.getLoadingState = getLoadingState;
|
|
51
|
+
exports.propsList = [
|
|
52
|
+
{
|
|
53
|
+
id: 0,
|
|
54
|
+
title: "query",
|
|
55
|
+
caption: "The graphQL query that fetches the collection",
|
|
56
|
+
value: "DocumentNode",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 1,
|
|
60
|
+
title: "queryOptions",
|
|
61
|
+
caption: "A list of options for us to pass into the apollo `useQuery` hook. \
|
|
62
|
+
Click to see more query options!",
|
|
63
|
+
url: "https://www.apollographql.com/docs/react/data/queries/#options",
|
|
64
|
+
value: "QueryHookOptions",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 2,
|
|
68
|
+
title: "getCollectionByPath",
|
|
69
|
+
caption: "A function that returns the location where the \
|
|
70
|
+
{@link Collection} is located. The collection is the part of the \
|
|
71
|
+
result that needs to be paginated.",
|
|
72
|
+
value: "GetCollectionByPathFunction<TQuery>",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 3,
|
|
76
|
+
title: "subscription (optional)",
|
|
77
|
+
caption: "A list of subscription options if \
|
|
78
|
+
you want to create a GraphQL subscription to listen for more content.",
|
|
79
|
+
value: "SubscriptionProps",
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
exports.subscriptionPropsList = [
|
|
83
|
+
{
|
|
84
|
+
id: 0,
|
|
85
|
+
title: "document",
|
|
86
|
+
caption: "The graphQL subscription that listens for more data. This query \
|
|
87
|
+
should return a single Node that matches the data structure in \
|
|
88
|
+
getCollectionByPath<TQuery>(...).edges.node and \
|
|
89
|
+
getCollectionByPath<TQuery>(...).nodes",
|
|
90
|
+
value: "DocumentNode",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 1,
|
|
94
|
+
title: "options",
|
|
95
|
+
caption: " A list of variables to pass into the apollo `subscribeToMore` function.",
|
|
96
|
+
value: "SubscribeToMoreOptions<TSubscription>",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 2,
|
|
100
|
+
title: "getNodeByPath",
|
|
101
|
+
caption: " A function that returns the location where the `Node` is \
|
|
102
|
+
located on the TSubscription object. It should return a single Node \
|
|
103
|
+
that matches the data structure in \
|
|
104
|
+
getCollectionByPath<TQuery>(...).edges.node and \
|
|
105
|
+
getCollectionByPath<TQuery>(...).nodes",
|
|
106
|
+
value: "GetNodeByPath<TSubscription>",
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
exports.returnValues = [
|
|
110
|
+
{
|
|
111
|
+
id: 0,
|
|
112
|
+
title: "data",
|
|
113
|
+
caption: "The payload returned from the query",
|
|
114
|
+
value: "ListQueryType | undefined",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 1,
|
|
118
|
+
title: "error",
|
|
119
|
+
caption: "Any errors returned from the query",
|
|
120
|
+
value: "ApolloError | undefined",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 2,
|
|
124
|
+
title: "refresh",
|
|
125
|
+
caption: "A funtion that enables you to re-execute the query",
|
|
126
|
+
value: "() => void",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 3,
|
|
130
|
+
title: "nextPage",
|
|
131
|
+
caption: "A funtion that helps you fetch the next set of results for a paginated list",
|
|
132
|
+
value: "() => void",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: 4,
|
|
136
|
+
title: "loadingRefresh",
|
|
137
|
+
caption: "An indicator that a refresh is in progress",
|
|
138
|
+
value: "boolean",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 5,
|
|
142
|
+
title: "loadingNextPage",
|
|
143
|
+
caption: "An indicator that a fetch more is in progress",
|
|
144
|
+
value: "boolean",
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: 6,
|
|
148
|
+
title: "loadingInitialContent",
|
|
149
|
+
caption: "An indicator that the initial content is being fetched",
|
|
150
|
+
value: "boolean",
|
|
151
|
+
},
|
|
152
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./queries"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./mocks"), exports);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { DocumentNode } from "@apollo/client";
|
|
3
|
+
import { MockedResponse } from "@apollo/react-testing";
|
|
4
|
+
import React from "react";
|
|
5
|
+
export declare function wrapper(mocks: MockedResponse[]): React.FunctionComponent<{}>;
|
|
6
|
+
export declare const listQueryResponseMock: jest.Mock<{
|
|
7
|
+
data: {
|
|
8
|
+
conversation: {
|
|
9
|
+
__typename: string;
|
|
10
|
+
smsMessages: {
|
|
11
|
+
__typename: string;
|
|
12
|
+
edges: {
|
|
13
|
+
__typename: string;
|
|
14
|
+
node: {
|
|
15
|
+
__typename: string;
|
|
16
|
+
id: any;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
nodes: {
|
|
20
|
+
__typename: string;
|
|
21
|
+
id: any;
|
|
22
|
+
}[];
|
|
23
|
+
pageInfo: {
|
|
24
|
+
__typename: string;
|
|
25
|
+
endCursor: string;
|
|
26
|
+
hasNextPage: boolean;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}, [id: any], any>;
|
|
32
|
+
export declare const listQueryWithTotalCountResponseMock: jest.Mock<{
|
|
33
|
+
data: {
|
|
34
|
+
conversation: {
|
|
35
|
+
__typename: string;
|
|
36
|
+
smsMessages: {
|
|
37
|
+
__typename: string;
|
|
38
|
+
edges: {
|
|
39
|
+
__typename: string;
|
|
40
|
+
node: {
|
|
41
|
+
__typename: string;
|
|
42
|
+
id: any;
|
|
43
|
+
};
|
|
44
|
+
}[];
|
|
45
|
+
nodes: {
|
|
46
|
+
__typename: string;
|
|
47
|
+
id: any;
|
|
48
|
+
}[];
|
|
49
|
+
pageInfo: {
|
|
50
|
+
__typename: string;
|
|
51
|
+
endCursor: string;
|
|
52
|
+
hasNextPage: boolean;
|
|
53
|
+
};
|
|
54
|
+
totalCount: number;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}, [id: any], any>;
|
|
59
|
+
export declare const subscriptionQueryMock: jest.Mock<{
|
|
60
|
+
data: {
|
|
61
|
+
conversationMessage: {
|
|
62
|
+
__typename: string;
|
|
63
|
+
id: string;
|
|
64
|
+
smsMessage: {
|
|
65
|
+
__typename: string;
|
|
66
|
+
id: any;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}, [id: any], any>;
|
|
71
|
+
export declare function buildListRequestMock(query: DocumentNode, responseMock: jest.Mock, id?: string | undefined, searchTerm?: string | undefined): {
|
|
72
|
+
request: {
|
|
73
|
+
query: DocumentNode;
|
|
74
|
+
variables: {
|
|
75
|
+
searchTerm: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
result: () => any;
|
|
79
|
+
};
|
|
80
|
+
export declare function buildSubscriptionRequestMock(id?: string | undefined): {
|
|
81
|
+
request: {
|
|
82
|
+
query: DocumentNode;
|
|
83
|
+
};
|
|
84
|
+
result: () => {
|
|
85
|
+
data: {
|
|
86
|
+
conversationMessage: {
|
|
87
|
+
__typename: string;
|
|
88
|
+
id: string;
|
|
89
|
+
smsMessage: {
|
|
90
|
+
__typename: string;
|
|
91
|
+
id: any;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
delay: number;
|
|
97
|
+
};
|
|
98
|
+
export declare function buildListRequestMockForNextPage(query: DocumentNode, responseMock: jest.Mock, id?: string | undefined): {
|
|
99
|
+
request: {
|
|
100
|
+
query: DocumentNode;
|
|
101
|
+
variables: {
|
|
102
|
+
cursor: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
result: () => any;
|
|
106
|
+
};
|
|
107
|
+
export declare function setListQueryMockHasNextPage(hasNextPage: boolean): void;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setListQueryMockHasNextPage = exports.buildListRequestMockForNextPage = exports.buildSubscriptionRequestMock = exports.buildListRequestMock = exports.subscriptionQueryMock = exports.listQueryWithTotalCountResponseMock = exports.listQueryResponseMock = exports.wrapper = void 0;
|
|
7
|
+
const react_testing_1 = require("@apollo/react-testing");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
const queries_1 = require("./queries");
|
|
11
|
+
function wrapper(mocks) {
|
|
12
|
+
function ApolloMockedProvider({ children, }) {
|
|
13
|
+
return (react_1.default.createElement(react_testing_1.MockedProvider, { addTypename: true, mocks: mocks }, children));
|
|
14
|
+
}
|
|
15
|
+
return ApolloMockedProvider;
|
|
16
|
+
}
|
|
17
|
+
exports.wrapper = wrapper;
|
|
18
|
+
let listQueryHasNextPage = true;
|
|
19
|
+
exports.listQueryResponseMock = jest.fn(id => {
|
|
20
|
+
return {
|
|
21
|
+
data: {
|
|
22
|
+
conversation: {
|
|
23
|
+
__typename: "Conversation",
|
|
24
|
+
smsMessages: {
|
|
25
|
+
__typename: "SMSMessageConnection",
|
|
26
|
+
edges: [
|
|
27
|
+
{
|
|
28
|
+
__typename: "SMSMessageEdge",
|
|
29
|
+
node: {
|
|
30
|
+
__typename: "SMSMessage",
|
|
31
|
+
id: id || (0, uuid_1.v1)(),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
nodes: [
|
|
36
|
+
{
|
|
37
|
+
__typename: "SMSMessage",
|
|
38
|
+
id: id || (0, uuid_1.v1)(),
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
pageInfo: {
|
|
42
|
+
__typename: "PageInfo",
|
|
43
|
+
endCursor: "MZ",
|
|
44
|
+
hasNextPage: listQueryHasNextPage,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
exports.listQueryWithTotalCountResponseMock = jest.fn(id => {
|
|
52
|
+
return {
|
|
53
|
+
data: {
|
|
54
|
+
conversation: {
|
|
55
|
+
__typename: "Conversation",
|
|
56
|
+
smsMessages: {
|
|
57
|
+
__typename: "SMSMessageConnection",
|
|
58
|
+
edges: [
|
|
59
|
+
{
|
|
60
|
+
__typename: "SMSMessageEdge",
|
|
61
|
+
node: {
|
|
62
|
+
__typename: "SMSMessage",
|
|
63
|
+
id: id || (0, uuid_1.v1)(),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
nodes: [
|
|
68
|
+
{
|
|
69
|
+
__typename: "SMSMessage",
|
|
70
|
+
id: id || (0, uuid_1.v1)(),
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
pageInfo: {
|
|
74
|
+
__typename: "PageInfo",
|
|
75
|
+
endCursor: "MZ",
|
|
76
|
+
hasNextPage: listQueryHasNextPage,
|
|
77
|
+
},
|
|
78
|
+
totalCount: 42,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
exports.subscriptionQueryMock = jest.fn(id => {
|
|
85
|
+
return {
|
|
86
|
+
data: {
|
|
87
|
+
conversationMessage: {
|
|
88
|
+
__typename: "conversationMessage",
|
|
89
|
+
id: "other stuff",
|
|
90
|
+
smsMessage: {
|
|
91
|
+
__typename: "SMSMessageData",
|
|
92
|
+
id: id,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
function buildListRequestMock(query, responseMock, id, searchTerm) {
|
|
99
|
+
return {
|
|
100
|
+
request: {
|
|
101
|
+
query: query,
|
|
102
|
+
variables: { searchTerm: searchTerm },
|
|
103
|
+
},
|
|
104
|
+
result: () => responseMock(id),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
exports.buildListRequestMock = buildListRequestMock;
|
|
108
|
+
function buildSubscriptionRequestMock(id) {
|
|
109
|
+
return {
|
|
110
|
+
request: {
|
|
111
|
+
query: queries_1.SUBSCRIPTION_QUERY,
|
|
112
|
+
},
|
|
113
|
+
result: () => (0, exports.subscriptionQueryMock)(id),
|
|
114
|
+
delay: 100,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
exports.buildSubscriptionRequestMock = buildSubscriptionRequestMock;
|
|
118
|
+
function buildListRequestMockForNextPage(query, responseMock, id) {
|
|
119
|
+
return {
|
|
120
|
+
request: {
|
|
121
|
+
query: query,
|
|
122
|
+
variables: { cursor: "MZ" },
|
|
123
|
+
},
|
|
124
|
+
result: () => responseMock(id),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
exports.buildListRequestMockForNextPage = buildListRequestMockForNextPage;
|
|
128
|
+
function setListQueryMockHasNextPage(hasNextPage) {
|
|
129
|
+
listQueryHasNextPage = hasNextPage;
|
|
130
|
+
}
|
|
131
|
+
exports.setListQueryMockHasNextPage = setListQueryMockHasNextPage;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const LIST_QUERY: import("@apollo/client").DocumentNode;
|
|
2
|
+
export declare const LIST_QUERY_WITH_TOTAL_COUNT: import("@apollo/client").DocumentNode;
|
|
3
|
+
export interface ListQueryType {
|
|
4
|
+
__typename?: "Query";
|
|
5
|
+
conversation?: {
|
|
6
|
+
__typename?: "Conversation";
|
|
7
|
+
smsMessages: {
|
|
8
|
+
edges: Array<{
|
|
9
|
+
__typename?: "SMSMessageConnection";
|
|
10
|
+
node: {
|
|
11
|
+
__typename?: "SMSMessage";
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
cursor: string;
|
|
15
|
+
}>;
|
|
16
|
+
nodes: Array<{
|
|
17
|
+
__typename?: "SMSMessage";
|
|
18
|
+
id: string;
|
|
19
|
+
}>;
|
|
20
|
+
pageInfo: {
|
|
21
|
+
endCursor: string;
|
|
22
|
+
hasNextPage: boolean;
|
|
23
|
+
};
|
|
24
|
+
totalCount?: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare const SUBSCRIPTION_QUERY: import("@apollo/client").DocumentNode;
|
|
29
|
+
export interface SubscriptionQueryType {
|
|
30
|
+
__typename?: "Subscription";
|
|
31
|
+
conversationMessage?: {
|
|
32
|
+
smsMessage: {
|
|
33
|
+
__typename?: "SMSMessage";
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_QUERY = exports.LIST_QUERY_WITH_TOTAL_COUNT = exports.LIST_QUERY = void 0;
|
|
4
|
+
const client_1 = require("@apollo/client");
|
|
5
|
+
exports.LIST_QUERY = (0, client_1.gql) `
|
|
6
|
+
query ConversationMessages($cursor: string, $searchTerm: string) {
|
|
7
|
+
conversation(id: "MQ==") {
|
|
8
|
+
smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {
|
|
9
|
+
edges {
|
|
10
|
+
node {
|
|
11
|
+
__typename
|
|
12
|
+
id
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
nodes {
|
|
16
|
+
__typename
|
|
17
|
+
id
|
|
18
|
+
}
|
|
19
|
+
pageInfo {
|
|
20
|
+
endCursor
|
|
21
|
+
hasNextPage
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
exports.LIST_QUERY_WITH_TOTAL_COUNT = (0, client_1.gql) `
|
|
28
|
+
query ConversationMessages($cursor: string, $searchTerm: string) {
|
|
29
|
+
conversation(id: "MQ==") {
|
|
30
|
+
smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {
|
|
31
|
+
edges {
|
|
32
|
+
node {
|
|
33
|
+
__typename
|
|
34
|
+
id
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
nodes {
|
|
38
|
+
__typename
|
|
39
|
+
id
|
|
40
|
+
}
|
|
41
|
+
pageInfo {
|
|
42
|
+
endCursor
|
|
43
|
+
hasNextPage
|
|
44
|
+
}
|
|
45
|
+
totalCount
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
exports.SUBSCRIPTION_QUERY = (0, client_1.gql) `
|
|
51
|
+
subscription ConversationMessage($conversationId: EncodedId!) {
|
|
52
|
+
conversationMessage(conversationId: $conversationId) {
|
|
53
|
+
smsMessage {
|
|
54
|
+
__typename
|
|
55
|
+
id
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function wait(milliseconds?: number): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.wait = void 0;
|
|
13
|
+
function wait(milliseconds = 0) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
yield new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.wait = wait;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqueEdges = exports.createEdge = void 0;
|
|
4
|
+
function createEdge(node) {
|
|
5
|
+
return {
|
|
6
|
+
node: node,
|
|
7
|
+
cursor: "",
|
|
8
|
+
__typename: `${node.__typename}Edge`,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.createEdge = createEdge;
|
|
12
|
+
function uniqueEdges(edges) {
|
|
13
|
+
const result = new Map();
|
|
14
|
+
edges.forEach(edge => {
|
|
15
|
+
result.set(`${edge.__typename}-${edge.node.__typename}-${edge.node.id}`, edge);
|
|
16
|
+
});
|
|
17
|
+
return Array.from(result.values());
|
|
18
|
+
}
|
|
19
|
+
exports.uniqueEdges = uniqueEdges;
|