@truedat/test 8.7.0 → 8.7.1
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/package.json +2 -2
- package/setup.js +2 -0
- package/src/__tests__/render.spec.js +6 -3
- package/src/mocks.js +2 -2
- package/src/render.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/test",
|
|
3
|
-
"version": "8.7.
|
|
3
|
+
"version": "8.7.1",
|
|
4
4
|
"description": "Truedat Web Test",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"react-test-renderer": "^19.1.0",
|
|
62
62
|
"redux": "^5.0.1"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f7605a6ea3f78839b42bb7d8339eec125ba49acb"
|
|
65
65
|
}
|
package/setup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { render, waitForLoad } from "../render";
|
|
2
1
|
import { screen, waitFor } from "@testing-library/react";
|
|
2
|
+
import { render, waitForLoad } from "../render";
|
|
3
3
|
|
|
4
4
|
describe("render utility", () => {
|
|
5
5
|
it("renders components with default options", () => {
|
|
@@ -33,9 +33,12 @@ describe("render utility", () => {
|
|
|
33
33
|
describe("waitForLoad", () => {
|
|
34
34
|
it("waits for loading indicators to disappear", async () => {
|
|
35
35
|
const TestComponent = () => (
|
|
36
|
-
<div
|
|
36
|
+
<div>
|
|
37
|
+
<div className="loader" data-testid="loader">
|
|
37
38
|
Loading...
|
|
38
|
-
</div
|
|
39
|
+
</div>
|
|
40
|
+
<div>Content</div>
|
|
41
|
+
</div>
|
|
39
42
|
);
|
|
40
43
|
|
|
41
44
|
const renderResult = render(<TestComponent />);
|
package/src/mocks.js
CHANGED
|
@@ -168,7 +168,7 @@ export const functionsMock = {
|
|
|
168
168
|
export const mockUseStructures = () => {
|
|
169
169
|
jest.mock("@truedat/dd/hooks/useStructures", () => {
|
|
170
170
|
const originalModule = jest.requireActual(
|
|
171
|
-
"@truedat/dd/hooks/useStructures"
|
|
171
|
+
"@truedat/dd/hooks/useStructures",
|
|
172
172
|
);
|
|
173
173
|
|
|
174
174
|
return {
|
|
@@ -198,7 +198,7 @@ export const mockUseStructures = () => {
|
|
|
198
198
|
export const mockUseConcepts = () =>
|
|
199
199
|
jest.mock("@truedat/bg/concepts/hooks/useConcepts", () => {
|
|
200
200
|
const originalModule = jest.requireActual(
|
|
201
|
-
"@truedat/bg/concepts/hooks/useConcepts"
|
|
201
|
+
"@truedat/bg/concepts/hooks/useConcepts",
|
|
202
202
|
);
|
|
203
203
|
|
|
204
204
|
return {
|
package/src/render.js
CHANGED
|
@@ -46,7 +46,7 @@ const customRender = (
|
|
|
46
46
|
fallback = <div>loading</div>,
|
|
47
47
|
dispatch,
|
|
48
48
|
...renderOptions
|
|
49
|
-
} = {}
|
|
49
|
+
} = {},
|
|
50
50
|
) => {
|
|
51
51
|
const store = configureStore({
|
|
52
52
|
preloadedState: state,
|
|
@@ -58,7 +58,7 @@ const customRender = (
|
|
|
58
58
|
const content = (
|
|
59
59
|
<MemoryRouter initialEntries={routes} initialIndex={routeIndex}>
|
|
60
60
|
<IntlProvider
|
|
61
|
-
onError={() => {
|
|
61
|
+
onError={() => {}}
|
|
62
62
|
locale={locale}
|
|
63
63
|
defaultLocale={locale}
|
|
64
64
|
messages={messages[locale]}
|
|
@@ -77,14 +77,14 @@ const customRender = (
|
|
|
77
77
|
content
|
|
78
78
|
);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
if (dispatch) store.dispatch = dispatch;
|
|
82
82
|
return render(component, { wrapper: Wrapper, ...renderOptions });
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
export const waitForLoad = async (
|
|
86
86
|
{ container, queryByText },
|
|
87
|
-
fallback = /loading/i
|
|
87
|
+
fallback = /loading/i,
|
|
88
88
|
) => {
|
|
89
89
|
await waitFor(() => {
|
|
90
90
|
if (fallback) expect(queryByText(fallback)).not.toBeInTheDocument();
|