@truedat/cx 7.5.7 → 7.5.10

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.
Files changed (110) hide show
  1. package/package.json +40 -70
  2. package/src/configurations/components/Configuration.js +3 -3
  3. package/src/configurations/components/ConfigurationActions.js +1 -2
  4. package/src/configurations/components/ConfigurationBreadcrumbs.js +2 -3
  5. package/src/configurations/components/ConfigurationCards.js +1 -2
  6. package/src/configurations/components/ConfigurationForm.js +6 -11
  7. package/src/configurations/components/ConfigurationLoader.js +1 -2
  8. package/src/configurations/components/ConfigurationRoutes.js +61 -72
  9. package/src/configurations/components/ConfigurationTokenLoader.js +0 -1
  10. package/src/configurations/components/Configurations.js +2 -2
  11. package/src/configurations/components/ConfigurationsLoader.js +0 -1
  12. package/src/configurations/components/DynamicConfigurationForm.js +5 -7
  13. package/src/configurations/components/EditConfiguration.js +0 -1
  14. package/src/configurations/components/NewConfiguration.js +0 -1
  15. package/src/configurations/components/__tests__/Configuration.spec.js +17 -10
  16. package/src/configurations/components/__tests__/ConfigurationCards.spec.js +22 -13
  17. package/src/configurations/components/__tests__/ConfigurationForm.spec.js +5 -5
  18. package/src/configurations/components/__tests__/ConfigurationLoader.spec.js +44 -36
  19. package/src/configurations/components/__tests__/ConfigurationTokenLoader.spec.js +46 -45
  20. package/src/configurations/components/__tests__/Configurations.spec.js +20 -22
  21. package/src/configurations/components/__tests__/ConfigurationsLoader.spec.js +32 -33
  22. package/src/configurations/components/__tests__/EditConfiguration.spec.js +5 -5
  23. package/src/configurations/components/__tests__/NewConfiguration.spec.js +0 -1
  24. package/src/configurations/components/__tests__/__snapshots__/Configuration.spec.js.snap +122 -57
  25. package/src/configurations/components/__tests__/__snapshots__/ConfigurationCards.spec.js.snap +160 -361
  26. package/src/configurations/components/__tests__/__snapshots__/ConfigurationForm.spec.js.snap +7 -6
  27. package/src/configurations/components/__tests__/__snapshots__/ConfigurationLoader.spec.js.snap +5 -31
  28. package/src/configurations/components/__tests__/__snapshots__/ConfigurationTokenLoader.spec.js.snap +5 -9
  29. package/src/configurations/components/__tests__/__snapshots__/Configurations.spec.js.snap +91 -72
  30. package/src/configurations/components/__tests__/__snapshots__/ConfigurationsLoader.spec.js.snap +5 -27
  31. package/src/configurations/components/__tests__/__snapshots__/EditConfiguration.spec.js.snap +12 -10
  32. package/src/configurations/components/__tests__/__snapshots__/NewConfiguration.spec.js.snap +11 -9
  33. package/src/configurations/components/index.js +1 -1
  34. package/src/configurations/reducers/configurationRedirect.js +1 -1
  35. package/src/configurations/reducers/configurations.js +1 -1
  36. package/src/configurations/reducers/index.js +1 -1
  37. package/src/configurations/reducers/systemConfigurations.js +1 -1
  38. package/src/configurations/sagas/signConfiguration.js +3 -1
  39. package/src/jobs/components/Job.js +0 -1
  40. package/src/jobs/components/JobBreadcrumbs.js +2 -3
  41. package/src/jobs/components/JobLoader.js +2 -2
  42. package/src/jobs/components/JobRoutes.js +28 -40
  43. package/src/jobs/components/JobRow.js +4 -4
  44. package/src/jobs/components/Jobs.js +5 -4
  45. package/src/jobs/components/JobsLabelResults.js +2 -3
  46. package/src/jobs/components/JobsSearch.js +0 -1
  47. package/src/jobs/components/JobsTable.js +3 -3
  48. package/src/jobs/components/JobsView.js +0 -1
  49. package/src/jobs/components/SourceJobs.js +0 -1
  50. package/src/jobs/components/__tests__/Job.spec.js +9 -11
  51. package/src/jobs/components/__tests__/JobBreadcrumbs.spec.js +5 -5
  52. package/src/jobs/components/__tests__/JobLoader.spec.js +12 -12
  53. package/src/jobs/components/__tests__/JobRow.spec.js +21 -20
  54. package/src/jobs/components/__tests__/Jobs.spec.js +1 -7
  55. package/src/jobs/components/__tests__/JobsLoader.spec.js +9 -9
  56. package/src/jobs/components/__tests__/JobsTable.spec.js +33 -28
  57. package/src/jobs/components/__tests__/JobsView.spec.js +1 -7
  58. package/src/jobs/components/__tests__/SourceJobs.spec.js +1 -7
  59. package/src/jobs/components/__tests__/__snapshots__/Job.spec.js.snap +143 -36
  60. package/src/jobs/components/__tests__/__snapshots__/JobBreadcrumbs.spec.js.snap +20 -30
  61. package/src/jobs/components/__tests__/__snapshots__/Jobs.spec.js.snap +10 -23
  62. package/src/jobs/components/__tests__/__snapshots__/JobsTable.spec.js.snap +7 -7
  63. package/src/jobs/components/__tests__/__snapshots__/JobsView.spec.js.snap +12 -24
  64. package/src/jobs/components/__tests__/__snapshots__/SourceJobs.spec.js.snap +8 -21
  65. package/src/jobs/reducers/jobActiveFilters.js +1 -1
  66. package/src/jobs/sagas/fetchJob.js +1 -1
  67. package/src/jobs/selectors/jobColumnsSelector.js +0 -1
  68. package/src/jobs/selectors/sourceJobColumnsSelector.js +0 -1
  69. package/src/sources/components/EditSource.js +0 -1
  70. package/src/sources/components/JobForm.js +1 -1
  71. package/src/sources/components/NewJob.js +0 -1
  72. package/src/sources/components/NewSource.js +0 -1
  73. package/src/sources/components/Source.js +0 -1
  74. package/src/sources/components/SourceActions.js +1 -2
  75. package/src/sources/components/SourceBreadcrumbs.js +1 -2
  76. package/src/sources/components/SourceConfiguration.js +3 -3
  77. package/src/sources/components/SourceDetail.js +46 -50
  78. package/src/sources/components/SourceForm.js +4 -7
  79. package/src/sources/components/SourceHeader.js +0 -1
  80. package/src/sources/components/SourceRoutes.js +30 -23
  81. package/src/sources/components/SourceSelector.js +0 -1
  82. package/src/sources/components/SourceTabs.js +14 -7
  83. package/src/sources/components/Sources.js +2 -2
  84. package/src/sources/components/SourcesTable.js +1 -2
  85. package/src/sources/components/__tests__/EditSource.spec.js +10 -12
  86. package/src/sources/components/__tests__/NewSource.spec.js +5 -10
  87. package/src/sources/components/__tests__/Source.spec.js +19 -27
  88. package/src/sources/components/__tests__/SourceActions.spec.js +1 -2
  89. package/src/sources/components/__tests__/SourceBreadcrumbs.spec.js +0 -1
  90. package/src/sources/components/__tests__/SourceDetail.spec.js +62 -38
  91. package/src/sources/components/__tests__/SourceForm.spec.js +109 -86
  92. package/src/sources/components/__tests__/SourceHeader.spec.js +1 -2
  93. package/src/sources/components/__tests__/SourceRoutes.spec.js +79 -7
  94. package/src/sources/components/__tests__/SourceSelector.spec.js +0 -1
  95. package/src/sources/components/__tests__/SourceTabs.spec.js +3 -4
  96. package/src/sources/components/__tests__/Sources.spec.js +24 -39
  97. package/src/sources/components/__tests__/SourcesTable.spec.js +48 -65
  98. package/src/sources/components/__tests__/__snapshots__/EditSource.spec.js.snap +134 -15
  99. package/src/sources/components/__tests__/__snapshots__/NewSource.spec.js.snap +36 -23
  100. package/src/sources/components/__tests__/__snapshots__/Source.spec.js.snap +28 -31
  101. package/src/sources/components/__tests__/__snapshots__/SourceActions.spec.js.snap +1 -1
  102. package/src/sources/components/__tests__/__snapshots__/SourceBreadcrumbs.spec.js.snap +2 -1
  103. package/src/sources/components/__tests__/__snapshots__/SourceDetail.spec.js.snap +13 -172
  104. package/src/sources/components/__tests__/__snapshots__/SourceForm.spec.js.snap +132 -106
  105. package/src/sources/components/__tests__/__snapshots__/SourceHeader.spec.js.snap +4 -4
  106. package/src/sources/components/__tests__/__snapshots__/SourceRoutes.spec.js.snap +47 -5
  107. package/src/sources/components/__tests__/__snapshots__/SourceTabs.spec.js.snap +5 -3
  108. package/src/sources/components/__tests__/__snapshots__/Sources.spec.js.snap +14 -11
  109. package/src/sources/components/__tests__/__snapshots__/SourcesTable.spec.js.snap +17 -12
  110. package/src/jobs/components/ConfigurationRoutes.js +0 -31
@@ -1,72 +1,80 @@
1
- import React from "react";
2
- import { mount, shallow } from "enzyme";
1
+ import { render, waitForLoad } from "@truedat/test/render";
3
2
  import { ConfigurationLoader } from "../ConfigurationLoader";
4
3
 
5
- jest.mock("react-router-dom", () => ({
6
- ...jest.requireActual("react-router-dom"),
7
- useParams: () => ({ external_id: 1 })
4
+ jest.mock("react-router", () => ({
5
+ ...jest.requireActual("react-router"),
6
+ useParams: () => ({ external_id: 1 }),
8
7
  }));
9
8
 
10
9
  describe("<ConfigurationLoader />", () => {
11
- const configurationLoading = false;
12
10
  const fetchConfiguration = jest.fn();
13
11
  const clearConfiguration = jest.fn();
14
12
 
15
- it("matches the latest snapshot", () => {
16
- const configurationLoading = true;
13
+ const renderOpts = {
14
+ state: {
15
+ configurations: {
16
+ loading: false,
17
+ },
18
+ },
19
+ dispatch: jest.fn(),
20
+ };
21
+
22
+ it("matches the latest snapshot", async () => {
17
23
  const props = {
18
24
  clearConfiguration,
19
25
  fetchConfiguration,
20
- configurationLoading
26
+ configurationLoading: true,
21
27
  };
22
- const wrapper = mount(<ConfigurationLoader {...props} />);
23
- expect(wrapper).toMatchSnapshot();
28
+ const rendered = render(<ConfigurationLoader {...props} />, renderOpts);
29
+ expect(rendered.container).toMatchSnapshot();
24
30
  });
25
31
 
26
- it("renders a loader if configurationLoading is true", () => {
27
- const configurationLoading = true;
32
+ it("renders a loader if configurationLoading is true", async () => {
28
33
  const props = {
29
34
  clearConfiguration,
30
35
  fetchConfiguration,
31
- configurationLoading
36
+ configurationLoading: true,
32
37
  };
33
- const wrapper = mount(<ConfigurationLoader {...props} />);
34
- expect(wrapper.find("Loading").length).toBe(1);
38
+ const rendered = render(<ConfigurationLoader {...props} />, renderOpts);
39
+ expect(rendered.container.querySelector(".loader")).toBeInTheDocument();
35
40
  });
36
41
 
37
- it("renders null if configurationLoading is false", () => {
42
+ it("renders null if configurationLoading is false", async () => {
38
43
  const props = {
39
44
  clearConfiguration,
40
45
  fetchConfiguration,
41
- configurationLoading: false
46
+ configurationLoading: false,
42
47
  };
43
- const wrapper = shallow(<ConfigurationLoader {...props} />);
44
- expect(wrapper.getElement()).toBeNull();
48
+ const rendered = render(<ConfigurationLoader {...props} />, renderOpts);
49
+ await waitForLoad(rendered);
50
+ expect(rendered.container).toBeEmptyDOMElement();
45
51
  });
46
52
 
47
- it("calls fetchConfiguration when component mounts but not when it unmounts", () => {
48
- const fetchConfiguration = jest.fn();
53
+ it("calls fetchConfiguration when component mounts but not when it unmounts", async () => {
54
+ const fetchConfigurationMock = jest.fn();
49
55
  const props = {
50
56
  clearConfiguration,
51
- fetchConfiguration,
52
- configurationLoading
57
+ fetchConfiguration: fetchConfigurationMock,
58
+ configurationLoading: false,
53
59
  };
54
- const wrapper = mount(<ConfigurationLoader {...props} />);
55
- expect(fetchConfiguration.mock.calls.length).toBe(1);
56
- wrapper.unmount();
57
- expect(fetchConfiguration.mock.calls.length).toBe(1);
60
+ const rendered = render(<ConfigurationLoader {...props} />, renderOpts);
61
+ await waitForLoad(rendered);
62
+ expect(fetchConfigurationMock).toHaveBeenCalledTimes(1);
63
+ rendered.unmount();
64
+ expect(fetchConfigurationMock).toHaveBeenCalledTimes(1);
58
65
  });
59
66
 
60
- it("calls clearConfiguration when component unmounts but not when it mounts", () => {
61
- const clearConfiguration = jest.fn();
67
+ it("calls clearConfiguration when component unmounts but not when it mounts", async () => {
68
+ const clearConfigurationMock = jest.fn();
62
69
  const props = {
63
- clearConfiguration,
70
+ clearConfiguration: clearConfigurationMock,
64
71
  fetchConfiguration,
65
- configurationLoading
72
+ configurationLoading: false,
66
73
  };
67
- const wrapper = mount(<ConfigurationLoader {...props} />);
68
- expect(clearConfiguration.mock.calls.length).toBe(0);
69
- wrapper.unmount();
70
- expect(clearConfiguration.mock.calls.length).toBe(1);
74
+ const rendered = render(<ConfigurationLoader {...props} />, renderOpts);
75
+ await waitForLoad(rendered);
76
+ expect(clearConfigurationMock).not.toHaveBeenCalled();
77
+ rendered.unmount();
78
+ expect(clearConfigurationMock).toHaveBeenCalledTimes(1);
71
79
  });
72
80
  });
@@ -1,9 +1,7 @@
1
- import React from "react";
2
- import { mount, shallow } from "enzyme";
1
+ import { render, waitForLoad } from "@truedat/test/render";
3
2
  import { ConfigurationTokenLoader } from "../ConfigurationTokenLoader";
4
3
 
5
4
  describe("<ConfigurationTokenLoader />", () => {
6
- const configurationTokenLoading = false;
7
5
  const clearDashboardDomains = jest.fn();
8
6
  const clearConfigurationToken = jest.fn();
9
7
  const signConfiguration = jest.fn();
@@ -11,21 +9,21 @@ describe("<ConfigurationTokenLoader />", () => {
11
9
  const dashboardDomains = [1, 2];
12
10
  const externalId = "externalId";
13
11
 
14
- it("matches the latest snapshot", () => {
12
+ it("matches the latest snapshot", async () => {
15
13
  const props = {
16
14
  clearDashboardDomains,
17
15
  clearConfigurationToken,
18
- configurationTokenLoading,
16
+ configurationTokenLoading: true,
19
17
  dashboardId,
20
18
  dashboardDomains: [],
21
19
  externalId,
22
- signConfiguration
20
+ signConfiguration,
23
21
  };
24
- const wrapper = mount(<ConfigurationTokenLoader {...props} />);
25
- expect(wrapper).toMatchSnapshot();
22
+ const rendered = render(<ConfigurationTokenLoader {...props} />);
23
+ expect(rendered.container).toMatchSnapshot();
26
24
  });
27
25
 
28
- it("renders a loader if configurationTokenLoading is true", () => {
26
+ it("renders a loader if configurationTokenLoading is true", async () => {
29
27
  const props = {
30
28
  clearDashboardDomains,
31
29
  clearConfigurationToken,
@@ -33,76 +31,79 @@ describe("<ConfigurationTokenLoader />", () => {
33
31
  dashboardId,
34
32
  dashboardDomains,
35
33
  externalId,
36
- signConfiguration
34
+ signConfiguration,
37
35
  };
38
- const wrapper = mount(<ConfigurationTokenLoader {...props} />);
39
- expect(wrapper.find("Loading").length).toBe(1);
36
+ const rendered = render(<ConfigurationTokenLoader {...props} />);
37
+ expect(rendered.container.querySelector(".loader")).toBeInTheDocument();
40
38
  });
41
39
 
42
- it("renders null if configurationTokenLoading is false", () => {
40
+ it("renders null if configurationTokenLoading is false", async () => {
43
41
  const props = {
44
42
  clearDashboardDomains,
45
43
  clearConfigurationToken,
46
- configurationTokenLoading,
44
+ configurationTokenLoading: false,
47
45
  dashboardId,
48
46
  dashboardDomains,
49
47
  externalId,
50
- signConfiguration
48
+ signConfiguration,
51
49
  };
52
- const wrapper = shallow(<ConfigurationTokenLoader {...props} />);
53
- expect(wrapper.getElement()).toBeNull();
50
+ const rendered = render(<ConfigurationTokenLoader {...props} />);
51
+ await waitForLoad(rendered);
52
+ expect(rendered.container).toBeEmptyDOMElement();
54
53
  });
55
54
 
56
- it("calls signConfiguration when component mounts but not when it unmounts", () => {
57
- signConfiguration.mockClear();
55
+ it("calls signConfiguration when component mounts but not when it unmounts", async () => {
56
+ const signConfigurationMock = jest.fn();
58
57
  const props = {
59
58
  clearDashboardDomains,
60
59
  clearConfigurationToken,
61
- configurationTokenLoading,
60
+ configurationTokenLoading: false,
62
61
  dashboardId,
63
62
  dashboardDomains,
64
63
  externalId,
65
- signConfiguration
64
+ signConfiguration: signConfigurationMock,
66
65
  };
67
- const wrapper = mount(<ConfigurationTokenLoader {...props} />);
68
- expect(signConfiguration.mock.calls.length).toBe(1);
69
- wrapper.unmount();
70
- expect(signConfiguration.mock.calls.length).toBe(1);
66
+ const rendered = render(<ConfigurationTokenLoader {...props} />);
67
+ await waitForLoad(rendered);
68
+ expect(signConfigurationMock).toHaveBeenCalledTimes(1);
69
+ rendered.unmount();
70
+ expect(signConfigurationMock).toHaveBeenCalledTimes(1);
71
71
  });
72
72
 
73
- it("does not call signConfiguration when component mounts and dashboardDomains are empty", () => {
74
- signConfiguration.mockClear();
73
+ it("does not call signConfiguration when component mounts and dashboardDomains are empty", async () => {
74
+ const signConfigurationMock = jest.fn();
75
75
  const props = {
76
76
  clearDashboardDomains,
77
77
  clearConfigurationToken,
78
- configurationTokenLoading,
78
+ configurationTokenLoading: false,
79
79
  dashboardId,
80
80
  dashboardDomains: [],
81
81
  externalId,
82
- signConfiguration
82
+ signConfiguration: signConfigurationMock,
83
83
  };
84
- mount(<ConfigurationTokenLoader {...props} />);
85
- expect(signConfiguration.mock.calls.length).toBe(0);
84
+ const rendered = render(<ConfigurationTokenLoader {...props} />);
85
+ await waitForLoad(rendered);
86
+ expect(signConfigurationMock).not.toHaveBeenCalled();
86
87
  });
87
88
 
88
- it("calls clearConfigurationToken and clearDashboardDomains when component unmounts but not when it mounts", () => {
89
- clearDashboardDomains.mockClear();
90
- clearConfigurationToken.mockClear();
91
-
89
+ it("calls clearConfigurationToken and clearDashboardDomains when component unmounts but not when it mounts", async () => {
90
+ const clearDashboardDomainsMock = jest.fn();
91
+ const clearConfigurationTokenMock = jest.fn();
92
92
  const props = {
93
- clearDashboardDomains,
94
- clearConfigurationToken,
95
- configurationTokenLoading,
93
+ clearDashboardDomains: clearDashboardDomainsMock,
94
+ clearConfigurationToken: clearConfigurationTokenMock,
95
+ configurationTokenLoading: false,
96
96
  dashboardId,
97
97
  dashboardDomains,
98
98
  externalId,
99
- signConfiguration
99
+ signConfiguration,
100
100
  };
101
- const wrapper = mount(<ConfigurationTokenLoader {...props} />);
102
- expect(clearDashboardDomains.mock.calls.length).toBe(0);
103
- expect(clearConfigurationToken.mock.calls.length).toBe(0);
104
- wrapper.unmount();
105
- expect(clearDashboardDomains.mock.calls.length).toBe(1);
106
- expect(clearConfigurationToken.mock.calls.length).toBe(1);
101
+ const rendered = render(<ConfigurationTokenLoader {...props} />);
102
+ await waitForLoad(rendered);
103
+ expect(clearDashboardDomainsMock).not.toHaveBeenCalled();
104
+ expect(clearConfigurationTokenMock).not.toHaveBeenCalled();
105
+ rendered.unmount();
106
+ expect(clearDashboardDomainsMock).toHaveBeenCalledTimes(1);
107
+ expect(clearConfigurationTokenMock).toHaveBeenCalledTimes(1);
107
108
  });
108
109
  });
@@ -1,38 +1,36 @@
1
- import React from "react";
2
- import { intl } from "@truedat/test/intl-stub";
3
- import { shallow } from "enzyme";
1
+ import userEvent from "@testing-library/user-event";
2
+ import { render, waitForLoad } from "@truedat/test/render";
4
3
  import { Configurations } from "../Configurations";
5
4
 
6
- // workaround for enzyme issue with React.useContext
7
- // see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
8
- jest.spyOn(React, "useContext").mockImplementation(() => intl);
9
-
10
5
  describe("<Configurations />", () => {
11
6
  const defaultProps = {
12
7
  configurationsLoading: false,
13
- configurations: [{ id: 1, external_id: "eid1" }]
8
+ configurations: [{ id: 1, external_id: "eid1", type: "test" }],
14
9
  };
15
10
 
16
- it("matches the latest snapshot", () => {
17
- const wrapper = shallow(<Configurations {...defaultProps} />);
18
- expect(wrapper).toMatchSnapshot();
11
+ it("matches the latest snapshot", async () => {
12
+ const rendered = render(<Configurations {...defaultProps} />);
13
+ await waitForLoad(rendered);
14
+ expect(rendered.container).toMatchSnapshot();
19
15
  });
20
16
 
21
- it("renders no results when configurations search result is empty", () => {
22
- const wrapper = shallow(<Configurations {...defaultProps} />);
23
- const inputSearch = wrapper.find("Input");
24
- inputSearch.simulate("change", {}, { value: "bank" });
25
- expect(
26
- wrapper.findWhere(n => n.prop("configurations")).props().configurations
27
- ).toEqual([]);
17
+ it("renders no results when configurations search result is empty", async () => {
18
+ const rendered = render(<Configurations {...defaultProps} />);
19
+ await waitForLoad(rendered);
20
+
21
+ const user = userEvent.setup({ delay: null });
22
+ const searchInput = rendered.getByPlaceholderText(/search/i);
23
+ await user.type(searchInput, "bank");
24
+
25
+ expect(rendered.queryByText(/eid1/i)).not.toBeInTheDocument();
28
26
  });
29
27
 
30
- it("renders null if configurationsLoading is false", () => {
28
+ it("renders null if configurationsLoading is true", async () => {
31
29
  const props = {
32
30
  configurations: [],
33
- configurationsLoading: true
31
+ configurationsLoading: true,
34
32
  };
35
- const wrapper = shallow(<Configurations {...props} />);
36
- expect(wrapper.getElement()).toBeNull();
33
+ const rendered = render(<Configurations {...props} />);
34
+ expect(rendered.container).toBeEmptyDOMElement();
37
35
  });
38
36
  });
@@ -1,67 +1,66 @@
1
- import React from "react";
2
- import { mount, shallow } from "enzyme";
1
+ import { render, waitForLoad } from "@truedat/test/render";
3
2
  import { ConfigurationsLoader } from "../ConfigurationsLoader";
4
3
 
5
4
  describe("<ConfigurationsLoader />", () => {
6
- const configurationsLoading = false;
7
5
  const fetchConfigurations = jest.fn();
8
6
  const clearConfigurations = jest.fn();
9
7
 
10
- it("matches the latest snapshot", () => {
11
- const configurationsLoading = true;
8
+ it("matches the latest snapshot", async () => {
12
9
  const props = {
13
10
  clearConfigurations,
14
11
  fetchConfigurations,
15
- configurationsLoading
12
+ configurationsLoading: true,
16
13
  };
17
- const wrapper = mount(<ConfigurationsLoader {...props} />);
18
- expect(wrapper).toMatchSnapshot();
14
+ const rendered = render(<ConfigurationsLoader {...props} />);
15
+ expect(rendered.container).toMatchSnapshot();
19
16
  });
20
17
 
21
- it("renders a loader if configurationsLoading is true", () => {
22
- const configurationsLoading = true;
18
+ it("renders a loader if configurationsLoading is true", async () => {
23
19
  const props = {
24
20
  clearConfigurations,
25
21
  fetchConfigurations,
26
- configurationsLoading
22
+ configurationsLoading: true,
27
23
  };
28
- const wrapper = mount(<ConfigurationsLoader {...props} />);
29
- expect(wrapper.find("Loading").length).toBe(1);
24
+ const rendered = render(<ConfigurationsLoader {...props} />);
25
+ expect(rendered.container.querySelector(".loader")).toBeInTheDocument();
30
26
  });
31
27
 
32
- it("renders null if configurationsLoading is false", () => {
28
+ it("renders null if configurationsLoading is false", async () => {
33
29
  const props = {
34
30
  clearConfigurations,
35
31
  fetchConfigurations,
36
- configurationsLoading: false
32
+ configurationsLoading: false,
37
33
  };
38
- const wrapper = shallow(<ConfigurationsLoader {...props} />);
39
- expect(wrapper.getElement()).toBeNull();
34
+ const rendered = render(<ConfigurationsLoader {...props} />);
35
+ await waitForLoad(rendered);
36
+ expect(rendered.container).toBeEmptyDOMElement();
40
37
  });
41
38
 
42
- it("calls fetchConfigurations when component mounts but not when it unmounts", () => {
43
- const fetchConfigurations = jest.fn();
39
+ it("calls fetchConfigurations when component mounts but not when it unmounts", async () => {
40
+ const fetchConfigurationsMock = jest.fn();
44
41
  const props = {
45
42
  clearConfigurations,
46
- fetchConfigurations,
47
- configurationsLoading
43
+ fetchConfigurations: fetchConfigurationsMock,
44
+ configurationsLoading: false,
48
45
  };
49
- const wrapper = mount(<ConfigurationsLoader {...props} />);
50
- expect(fetchConfigurations.mock.calls.length).toBe(1);
51
- wrapper.unmount();
52
- expect(fetchConfigurations.mock.calls.length).toBe(1);
46
+ const rendered = render(<ConfigurationsLoader {...props} />);
47
+ await waitForLoad(rendered);
48
+ expect(fetchConfigurationsMock).toHaveBeenCalledTimes(1);
49
+ rendered.unmount();
50
+ expect(fetchConfigurationsMock).toHaveBeenCalledTimes(1);
53
51
  });
54
52
 
55
- it("calls clearConfigurations when component unmounts but not when it mounts", () => {
56
- const clearConfigurations = jest.fn();
53
+ it("calls clearConfigurations when component unmounts but not when it mounts", async () => {
54
+ const clearConfigurationsMock = jest.fn();
57
55
  const props = {
58
- clearConfigurations,
56
+ clearConfigurations: clearConfigurationsMock,
59
57
  fetchConfigurations,
60
- configurationsLoading
58
+ configurationsLoading: false,
61
59
  };
62
- const wrapper = mount(<ConfigurationsLoader {...props} />);
63
- expect(clearConfigurations.mock.calls.length).toBe(0);
64
- wrapper.unmount();
65
- expect(clearConfigurations.mock.calls.length).toBe(1);
60
+ const rendered = render(<ConfigurationsLoader {...props} />);
61
+ await waitForLoad(rendered);
62
+ expect(clearConfigurationsMock).not.toHaveBeenCalled();
63
+ rendered.unmount();
64
+ expect(clearConfigurationsMock).toHaveBeenCalledTimes(1);
66
65
  });
67
66
  });
@@ -1,5 +1,4 @@
1
- import React from "react";
2
- import { render } from "@truedat/test/render";
1
+ import { render, waitForLoad } from "@truedat/test/render";
3
2
  import EditConfiguration from "../EditConfiguration";
4
3
 
5
4
  const renderOpts = {
@@ -14,8 +13,9 @@ const renderOpts = {
14
13
  };
15
14
 
16
15
  describe("<EditConfiguration />", () => {
17
- it("matches the latest snapshot", () => {
18
- const { container } = render(<EditConfiguration />, renderOpts);
19
- expect(container).toMatchSnapshot();
16
+ it("matches the latest snapshot", async () => {
17
+ const rendered = render(<EditConfiguration />, renderOpts);
18
+ await waitForLoad(rendered);
19
+ expect(rendered.container).toMatchSnapshot();
20
20
  });
21
21
  });
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { render } from "@truedat/test/render";
3
2
  import NewConfiguration from "../NewConfiguration";
4
3
 
@@ -1,68 +1,133 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<Configuration /> matches the latest snapshot 1`] = `
4
- <Fragment>
5
- <ConfigurationBreadcrumbs
6
- text="Micro1"
7
- />
8
- <Segment>
9
- <Grid>
10
- <GridColumn
11
- width={8}
4
+ <div>
5
+ <div
6
+ class="ui breadcrumb"
7
+ >
8
+ <a
9
+ class="section"
10
+ data-discover="true"
11
+ href="/configurations"
12
+ >
13
+ navigation.admin.configurations
14
+ </a>
15
+ <i
16
+ aria-hidden="true"
17
+ class="right angle icon divider"
18
+ />
19
+ <div
20
+ class="active section"
21
+ >
22
+ Micro1
23
+ </div>
24
+ </div>
25
+ <div
26
+ class="ui segment"
27
+ >
28
+ <div
29
+ class="ui grid"
30
+ >
31
+ <div
32
+ class="eight wide column"
12
33
  >
13
- <Header
14
- as="h2"
34
+ <h2
35
+ class="ui header"
15
36
  >
16
- <Icon
17
- as="i"
18
- circular={true}
19
- name="clipboard check"
37
+ <i
38
+ aria-hidden="true"
39
+ class="clipboard check circular icon"
20
40
  />
21
- <HeaderContent>
41
+ <div
42
+ class="content"
43
+ >
22
44
  Micro1
23
- <HeaderSubheader>
45
+ <div
46
+ class="sub header"
47
+ >
24
48
  micro
25
- </HeaderSubheader>
26
- </HeaderContent>
27
- </Header>
28
- </GridColumn>
29
- <GridColumn
30
- textAlign="right"
31
- width={8}
49
+ </div>
50
+ </div>
51
+ </h2>
52
+ </div>
53
+ <div
54
+ class="right aligned eight wide column"
32
55
  >
33
- <Connect(ConfigurationActions) />
34
- </GridColumn>
35
- <GridColumn
36
- width={8}
56
+ <div
57
+ aria-expanded="false"
58
+ class="ui floating dropdown button icon group-actions"
59
+ role="listbox"
60
+ tabindex="0"
61
+ >
62
+ <i
63
+ aria-hidden="true"
64
+ class="ellipsis vertical icon"
65
+ />
66
+ <div
67
+ class="left menu transition"
68
+ >
69
+ <a
70
+ aria-checked="false"
71
+ aria-selected="false"
72
+ class="item"
73
+ data-discover="true"
74
+ href="/configurations/Micro1/edit"
75
+ role="option"
76
+ style="pointer-events: all;"
77
+ >
78
+ <i
79
+ aria-hidden="true"
80
+ class="edit icon"
81
+ />
82
+ edit
83
+ </a>
84
+ <button
85
+ class="ui button"
86
+ >
87
+ <i
88
+ aria-hidden="true"
89
+ class="red trash alternate outline icon"
90
+ />
91
+ configurations.actions.remove
92
+ </button>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ <div
97
+ class="eight wide column"
37
98
  >
38
- <lazy
39
- template={
40
- {
41
- "content": [
42
- {
43
- "fields": [
44
- {
45
- "cardinality": "1",
46
- "disabled": true,
47
- "label": "a",
48
- "name": "a",
49
- "type": "string",
50
- "widget": "string",
51
- },
52
- ],
53
- "is_secret": false,
54
- "name": "New Group 1",
55
- },
56
- ],
57
- "id": 36,
58
- "label": "app-admin",
59
- "name": "micro",
60
- "scope": "ca",
61
- }
62
- }
63
- />
64
- </GridColumn>
65
- </Grid>
66
- </Segment>
67
- </Fragment>
99
+ <div
100
+ class="ui horizontal divider"
101
+ >
102
+ <h3>
103
+ New Group 1
104
+ </h3>
105
+ </div>
106
+ <div
107
+ class="ui big very relaxed list"
108
+ role="list"
109
+ >
110
+ <div
111
+ class="item"
112
+ role="listitem"
113
+ >
114
+ <div
115
+ class="header dynamic-field-header"
116
+ >
117
+ a
118
+ </div>
119
+ <div
120
+ class="description"
121
+ >
122
+ <i
123
+ aria-hidden="true"
124
+ class="grey minus icon"
125
+ />
126
+ </div>
127
+ </div>
128
+ </div>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div>
68
133
  `;