@truedat/test 4.44.4 → 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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [4.44.3] 2022-05-11
4
4
 
5
+ ### Added
6
+
7
+ - [TD-4230] Created `mocks` for common test mocking
8
+
9
+ ## [4.44.3] 2022-05-11
10
+
5
11
  ### Changed
6
12
 
7
13
  - Test renderer now uses combined i18n messages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/test",
3
- "version": "4.44.4",
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.14.8",
26
- "@babel/core": "^7.15.0",
27
- "@babel/plugin-proposal-class-properties": "^7.14.5",
28
- "@babel/plugin-proposal-object-rest-spread": "^7.14.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.15.0",
31
- "@babel/preset-env": "^7.15.0",
32
- "@babel/preset-react": "^7.14.5",
33
- "@testing-library/jest-dom": "^5.14.1",
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": "^27.0.6",
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": "^27.0.6",
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.10",
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": "36fb183e1d22181e6a15b3bac2c01b39214eacdb"
102
+ "gitHead": "5a339468198c803592b285eddd0dd0c0b0eced93"
98
103
  }
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
@@ -16,13 +16,14 @@ const customRender = (
16
16
  messages = defaultMessages,
17
17
  routes = ["/"],
18
18
  routeIndex,
19
+ fallback = false,
19
20
  ...renderOptions
20
21
  } = {}
21
22
  ) => {
22
23
  const store = createStore(() => state);
23
24
  // eslint-disable-next-line react/prop-types
24
25
  function Wrapper({ children }) {
25
- return (
26
+ const content = (
26
27
  <MemoryRouter initialEntries={routes} initialIndex={routeIndex}>
27
28
  <IntlProvider
28
29
  locale={locale}
@@ -37,6 +38,11 @@ const customRender = (
37
38
  </IntlProvider>
38
39
  </MemoryRouter>
39
40
  );
41
+ return fallback ? (
42
+ <React.Suspense fallback={fallback}>{content}</React.Suspense>
43
+ ) : (
44
+ content
45
+ );
40
46
  }
41
47
  return render(component, { wrapper: Wrapper, ...renderOptions });
42
48
  };