@truedat/test 4.44.2 → 4.44.5
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/CHANGELOG.md +12 -0
- package/package.json +20 -15
- package/src/messages.js +64 -0
- package/src/mocks.js +39 -0
- package/src/render.js +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.44.3] 2022-05-11
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- [TD-4230] Created `mocks` for common test mocking
|
|
8
|
+
|
|
9
|
+
## [4.44.3] 2022-05-11
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Test renderer now uses combined i18n messages
|
|
14
|
+
|
|
3
15
|
## [4.41.4] 2022-04-04
|
|
4
16
|
|
|
5
17
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/test",
|
|
3
|
-
"version": "4.44.
|
|
3
|
+
"version": "4.44.5",
|
|
4
4
|
"description": "Truedat Web Test",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -16,24 +16,25 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"clean": "rimraf yarn-error.log",
|
|
19
|
-
"test": "jest --coverage",
|
|
20
|
-
"test:watch": "jest --watch",
|
|
19
|
+
"test": "TZ=UTC jest --coverage",
|
|
20
|
+
"test:watch": "TZ=UTC jest --watch",
|
|
21
21
|
"eslint": "eslint src/**",
|
|
22
22
|
"eslint:fix": "eslint --fix src/**"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "^7.
|
|
26
|
-
"@babel/core": "^7.
|
|
27
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
28
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
25
|
+
"@babel/cli": "^7.17.10",
|
|
26
|
+
"@babel/core": "^7.18.0",
|
|
27
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
28
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
|
|
29
|
+
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
|
|
29
30
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
30
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
31
|
-
"@babel/preset-env": "^7.
|
|
32
|
-
"@babel/preset-react": "^7.
|
|
33
|
-
"@testing-library/jest-dom": "^5.
|
|
31
|
+
"@babel/plugin-transform-modules-commonjs": "^7.18.0",
|
|
32
|
+
"@babel/preset-env": "^7.18.0",
|
|
33
|
+
"@babel/preset-react": "^7.17.12",
|
|
34
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
34
35
|
"@testing-library/react": "^12.0.0",
|
|
35
36
|
"@testing-library/user-event": "^13.2.1",
|
|
36
|
-
"babel-jest": "^
|
|
37
|
+
"babel-jest": "^28.1.0",
|
|
37
38
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
38
39
|
"babel-plugin-lodash": "^3.3.4",
|
|
39
40
|
"babel-plugin-react-intl": "^5.1.18",
|
|
@@ -42,12 +43,15 @@
|
|
|
42
43
|
"enzyme-adapter-react-16": "^1.15.6",
|
|
43
44
|
"enzyme-to-json": "^3.6.2",
|
|
44
45
|
"identity-obj-proxy": "^3.0.0",
|
|
45
|
-
"jest": "^
|
|
46
|
+
"jest": "^28.1.0",
|
|
47
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
46
48
|
"react": "^16.14.0",
|
|
47
49
|
"react-dom": "^16.14.0",
|
|
48
50
|
"rimraf": "^3.0.2"
|
|
49
51
|
},
|
|
50
52
|
"jest": {
|
|
53
|
+
"maxWorkers": "50%",
|
|
54
|
+
"testTimeout": 10000,
|
|
51
55
|
"moduleDirectories": [
|
|
52
56
|
"<rootDir>/src",
|
|
53
57
|
"../../node_modules"
|
|
@@ -83,8 +87,9 @@
|
|
|
83
87
|
]
|
|
84
88
|
},
|
|
85
89
|
"dependencies": {
|
|
86
|
-
"@apollo/client": "^3.4
|
|
90
|
+
"@apollo/client": "^3.6.4",
|
|
87
91
|
"lodash": "^4.17.21",
|
|
92
|
+
"prop-types": "^15.8.1",
|
|
88
93
|
"react-intl": "^5.20.10",
|
|
89
94
|
"react-redux": "^7.2.4",
|
|
90
95
|
"react-router-dom": "^5.2.0",
|
|
@@ -94,5 +99,5 @@
|
|
|
94
99
|
"react": ">= 16.8.6 < 17",
|
|
95
100
|
"react-dom": ">= 16.8.6 < 17"
|
|
96
101
|
},
|
|
97
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "5a339468198c803592b285eddd0dd0c0b0eced93"
|
|
98
103
|
}
|
package/src/messages.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import coreEs from "@truedat/core/messages/es";
|
|
2
|
+
import coreEn from "@truedat/core/messages/en";
|
|
3
|
+
|
|
4
|
+
import auditEs from "@truedat/audit/messages/es";
|
|
5
|
+
import auditEn from "@truedat/audit/messages/en";
|
|
6
|
+
|
|
7
|
+
import authEs from "@truedat/auth/messages/es";
|
|
8
|
+
import authEn from "@truedat/auth/messages/en";
|
|
9
|
+
|
|
10
|
+
import bgEs from "@truedat/bg/messages/es";
|
|
11
|
+
import bgEn from "@truedat/bg/messages/en";
|
|
12
|
+
|
|
13
|
+
import ddEs from "@truedat/dd/messages/es";
|
|
14
|
+
import ddEn from "@truedat/dd/messages/en";
|
|
15
|
+
|
|
16
|
+
import dfEs from "@truedat/df/messages/es";
|
|
17
|
+
import dfEn from "@truedat/df/messages/en";
|
|
18
|
+
|
|
19
|
+
import dqEs from "@truedat/dq/messages/es";
|
|
20
|
+
import dqEn from "@truedat/dq/messages/en";
|
|
21
|
+
|
|
22
|
+
import ieEs from "@truedat/ie/messages/es";
|
|
23
|
+
import ieEn from "@truedat/ie/messages/en";
|
|
24
|
+
|
|
25
|
+
import seEs from "@truedat/se/messages/es";
|
|
26
|
+
import seEn from "@truedat/se/messages/en";
|
|
27
|
+
|
|
28
|
+
import lmEs from "@truedat/lm/messages/es";
|
|
29
|
+
import lmEn from "@truedat/lm/messages/en";
|
|
30
|
+
|
|
31
|
+
import cxEs from "@truedat/cx/messages/es";
|
|
32
|
+
import cxEn from "@truedat/cx/messages/en";
|
|
33
|
+
|
|
34
|
+
const combinedEs = {
|
|
35
|
+
...coreEs,
|
|
36
|
+
...auditEs,
|
|
37
|
+
...authEs,
|
|
38
|
+
...bgEs,
|
|
39
|
+
...ddEs,
|
|
40
|
+
...dfEs,
|
|
41
|
+
...dqEs,
|
|
42
|
+
...ieEs,
|
|
43
|
+
...seEs,
|
|
44
|
+
...lmEs,
|
|
45
|
+
...cxEs,
|
|
46
|
+
};
|
|
47
|
+
const combinedEn = {
|
|
48
|
+
...coreEn,
|
|
49
|
+
...auditEn,
|
|
50
|
+
...authEn,
|
|
51
|
+
...bgEn,
|
|
52
|
+
...ddEn,
|
|
53
|
+
...dfEn,
|
|
54
|
+
...dqEn,
|
|
55
|
+
...ieEn,
|
|
56
|
+
...seEn,
|
|
57
|
+
...lmEn,
|
|
58
|
+
...cxEn,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default {
|
|
62
|
+
es: combinedEs,
|
|
63
|
+
en: combinedEn,
|
|
64
|
+
};
|
package/src/mocks.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TEMPLATES_QUERY } from "@truedat/core/api/queries";
|
|
2
|
+
|
|
3
|
+
const template1 = {
|
|
4
|
+
__typename: "Template",
|
|
5
|
+
id: "1",
|
|
6
|
+
name: "template1",
|
|
7
|
+
label: "template1",
|
|
8
|
+
scope: "foo",
|
|
9
|
+
content: [
|
|
10
|
+
{
|
|
11
|
+
name: "g1",
|
|
12
|
+
fields: [{ name: "field1", label: "field1", placeholder: "field1" }],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const template2 = {
|
|
18
|
+
__typename: "Template",
|
|
19
|
+
id: "2",
|
|
20
|
+
name: "template2",
|
|
21
|
+
label: "template2",
|
|
22
|
+
scope: "foo",
|
|
23
|
+
content: [],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const multipleTemplatesMock = (variables) => ({
|
|
27
|
+
request: { query: TEMPLATES_QUERY, variables },
|
|
28
|
+
result: { data: { templates: [template1, template2] } },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const singleTemplateMock = (variables) => ({
|
|
32
|
+
request: { query: TEMPLATES_QUERY, variables },
|
|
33
|
+
result: { data: { templates: [template1] } },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const errorTemplateMock = (variables) => ({
|
|
37
|
+
request: { query: TEMPLATES_QUERY, variables },
|
|
38
|
+
error: new Error("Error fetching templates"),
|
|
39
|
+
});
|
package/src/render.js
CHANGED
|
@@ -5,6 +5,7 @@ import { IntlProvider } from "react-intl";
|
|
|
5
5
|
import { createStore } from "redux";
|
|
6
6
|
import { Provider } from "react-redux";
|
|
7
7
|
import { MemoryRouter } from "react-router-dom";
|
|
8
|
+
import defaultMessages from "./messages";
|
|
8
9
|
|
|
9
10
|
const customRender = (
|
|
10
11
|
component,
|
|
@@ -12,16 +13,17 @@ const customRender = (
|
|
|
12
13
|
locale = "en",
|
|
13
14
|
mocks = [],
|
|
14
15
|
state = {},
|
|
15
|
-
messages =
|
|
16
|
+
messages = defaultMessages,
|
|
16
17
|
routes = ["/"],
|
|
17
18
|
routeIndex,
|
|
19
|
+
fallback = false,
|
|
18
20
|
...renderOptions
|
|
19
|
-
}
|
|
21
|
+
} = {}
|
|
20
22
|
) => {
|
|
21
23
|
const store = createStore(() => state);
|
|
22
24
|
// eslint-disable-next-line react/prop-types
|
|
23
25
|
function Wrapper({ children }) {
|
|
24
|
-
|
|
26
|
+
const content = (
|
|
25
27
|
<MemoryRouter initialEntries={routes} initialIndex={routeIndex}>
|
|
26
28
|
<IntlProvider
|
|
27
29
|
locale={locale}
|
|
@@ -36,6 +38,11 @@ const customRender = (
|
|
|
36
38
|
</IntlProvider>
|
|
37
39
|
</MemoryRouter>
|
|
38
40
|
);
|
|
41
|
+
return fallback ? (
|
|
42
|
+
<React.Suspense fallback={fallback}>{content}</React.Suspense>
|
|
43
|
+
) : (
|
|
44
|
+
content
|
|
45
|
+
);
|
|
39
46
|
}
|
|
40
47
|
return render(component, { wrapper: Wrapper, ...renderOptions });
|
|
41
48
|
};
|