@trackunit/react-core-contexts-test 0.1.244 → 0.1.246
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.cjs.js +9 -9
- package/HookRenderer.esm.js +9 -9
- package/index.cjs.js +1167 -38
- package/index.esm.js +1149 -14
- package/package.json +6 -5
- package/src/ApolloMockedProviderWithError.d.ts +1 -2
- package/src/TrackunitProvidersMockBuilder.d.ts +3 -3
- package/src/debugger.d.ts +1 -1
- package/src/utils/queryFor.d.ts +1 -1
- package/src/utils/routingUtils.d.ts +2 -2
- package/index.cjs2.js +0 -1208
- package/index.esm2.js +0 -1182
package/HookRenderer.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index.cjs2.js');
|
|
4
3
|
var react = require('@testing-library/react');
|
|
5
4
|
var pure = require('@testing-library/react/pure');
|
|
5
|
+
var index = require('./index.cjs.js');
|
|
6
6
|
require('react/jsx-runtime');
|
|
7
7
|
require('@trackunit/react-core-hooks');
|
|
8
8
|
require('lodash/omit');
|
|
@@ -24,7 +24,7 @@ require('graphql');
|
|
|
24
24
|
* @param getMockedCompositionRoot A function that will return the mocked composition root.
|
|
25
25
|
* @returns { Promise<RenderHookResult> } The rendered hook.
|
|
26
26
|
*/
|
|
27
|
-
const reactHooksRenderHook = (callback, getMockedCompositionRoot) =>
|
|
27
|
+
const reactHooksRenderHook = async (callback, getMockedCompositionRoot) => {
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
29
|
const wrapper = ({ children }) => {
|
|
30
30
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
@@ -33,13 +33,13 @@ const reactHooksRenderHook = (callback, getMockedCompositionRoot) => index.__awa
|
|
|
33
33
|
let renderedHook;
|
|
34
34
|
// This is added here to make storybook work and to ensure the right act is loaded for hooks.
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
36
|
-
|
|
37
|
-
renderedHook =
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
36
|
+
await react.act(async () => {
|
|
37
|
+
renderedHook = await pure.renderHook(callback, { wrapper });
|
|
38
|
+
});
|
|
39
|
+
await react.act(async () => {
|
|
40
|
+
await index.flushPromises();
|
|
41
|
+
});
|
|
42
42
|
return renderedHook;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
|
|
45
45
|
exports.reactHooksRenderHook = reactHooksRenderHook;
|
package/HookRenderer.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as __awaiter, f as flushPromises } from './index.esm2.js';
|
|
2
1
|
import { act } from '@testing-library/react';
|
|
3
2
|
import { renderHook } from '@testing-library/react/pure';
|
|
3
|
+
import { flushPromises } from './index.esm.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import '@trackunit/react-core-hooks';
|
|
6
6
|
import 'lodash/omit';
|
|
@@ -22,7 +22,7 @@ import 'graphql';
|
|
|
22
22
|
* @param getMockedCompositionRoot A function that will return the mocked composition root.
|
|
23
23
|
* @returns { Promise<RenderHookResult> } The rendered hook.
|
|
24
24
|
*/
|
|
25
|
-
const reactHooksRenderHook = (callback, getMockedCompositionRoot) =>
|
|
25
|
+
const reactHooksRenderHook = async (callback, getMockedCompositionRoot) => {
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
27
|
const wrapper = ({ children }) => {
|
|
28
28
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
@@ -31,13 +31,13 @@ const reactHooksRenderHook = (callback, getMockedCompositionRoot) => __awaiter(v
|
|
|
31
31
|
let renderedHook;
|
|
32
32
|
// This is added here to make storybook work and to ensure the right act is loaded for hooks.
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
34
|
-
|
|
35
|
-
renderedHook =
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
34
|
+
await act(async () => {
|
|
35
|
+
renderedHook = await renderHook(callback, { wrapper });
|
|
36
|
+
});
|
|
37
|
+
await act(async () => {
|
|
38
|
+
await flushPromises();
|
|
39
|
+
});
|
|
40
40
|
return renderedHook;
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
|
|
43
43
|
export { reactHooksRenderHook };
|