@trackunit/react-core-contexts-test 0.0.7 → 0.0.8
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/HookRenderer.js +1 -0
- package/index.js +1 -0
- package/index2.js +14 -2
- package/package.json +1 -1
- package/utils/queryFor.d.ts +1 -1
package/HookRenderer.js
CHANGED
|
@@ -10,6 +10,7 @@ import 'react-router-dom';
|
|
|
10
10
|
import '@apollo/client';
|
|
11
11
|
import '@apollo/client/link/error';
|
|
12
12
|
import '@apollo/client/testing';
|
|
13
|
+
import 'graphql';
|
|
13
14
|
|
|
14
15
|
const reactHooksRenderHook = (callback, getMockedCompositionRoot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/index.js
CHANGED
package/index2.js
CHANGED
|
@@ -7,6 +7,7 @@ import { MemoryRouter } from 'react-router-dom';
|
|
|
7
7
|
import { ApolloLink } from '@apollo/client';
|
|
8
8
|
import { onError } from '@apollo/client/link/error';
|
|
9
9
|
import { MockLink, MockedProvider } from '@apollo/client/testing';
|
|
10
|
+
import { GraphQLError } from 'graphql';
|
|
10
11
|
|
|
11
12
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
12
13
|
|
|
@@ -2259,6 +2260,15 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
2259
2260
|
});
|
|
2260
2261
|
}
|
|
2261
2262
|
|
|
2263
|
+
const defaultOptions = {
|
|
2264
|
+
mutate: {
|
|
2265
|
+
errorPolicy: "all"
|
|
2266
|
+
},
|
|
2267
|
+
query: {
|
|
2268
|
+
errorPolicy: "all"
|
|
2269
|
+
}
|
|
2270
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2271
|
+
|
|
2262
2272
|
function ApolloMockedProviderWithError(props) {
|
|
2263
2273
|
const {
|
|
2264
2274
|
mocks
|
|
@@ -2293,7 +2303,8 @@ function ApolloMockedProviderWithError(props) {
|
|
|
2293
2303
|
});
|
|
2294
2304
|
const link = ApolloLink.from([errorLoggingLink, mockLink]);
|
|
2295
2305
|
return jsx(MockedProvider, Object.assign({}, otherProps, {
|
|
2296
|
-
link: link
|
|
2306
|
+
link: link,
|
|
2307
|
+
defaultOptions: defaultOptions
|
|
2297
2308
|
}));
|
|
2298
2309
|
}
|
|
2299
2310
|
|
|
@@ -2571,6 +2582,7 @@ const doNothing = () => {
|
|
|
2571
2582
|
* @returns MockedResponse that can be passed to the mocked ApolloProvider.
|
|
2572
2583
|
* @see [Testing React components using MockedProvider and associated APIs](https://www.apollographql.com/docs/react/development-testing/testing/)
|
|
2573
2584
|
*/
|
|
2585
|
+
|
|
2574
2586
|
const queryFor = (document, variables, data, error) => {
|
|
2575
2587
|
return {
|
|
2576
2588
|
request: {
|
|
@@ -2587,7 +2599,7 @@ const queryFor = (document, variables, data, error) => {
|
|
|
2587
2599
|
|
|
2588
2600
|
return {
|
|
2589
2601
|
data,
|
|
2590
|
-
error
|
|
2602
|
+
errors: error ? [new GraphQLError(error.message)] : undefined
|
|
2591
2603
|
};
|
|
2592
2604
|
}
|
|
2593
2605
|
};
|
package/package.json
CHANGED
package/utils/queryFor.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ import { DocumentNode } from "graphql";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const queryFor: <Result extends {
|
|
17
17
|
__typename?: unknown;
|
|
18
|
-
}, Variables>(document: DocumentNode, variables: Variables, data: Result, error?: ApolloError) => MockedResponse;
|
|
18
|
+
}, Variables>(document: DocumentNode, variables: Variables, data: Result | null, error?: ApolloError | Error) => MockedResponse;
|