@truedat/audit 4.44.1 → 4.44.4

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 (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +5 -5
  3. package/src/components/EventsLoader.js +15 -11
  4. package/src/components/NotificationEvent.js +12 -1
  5. package/src/components/ShareLinkForm.js +2 -4
  6. package/src/components/Subscription.js +43 -22
  7. package/src/components/SubscriptionEdit.js +33 -18
  8. package/src/components/SubscriptionForm.js +6 -2
  9. package/src/components/SubscriptionLoader.js +26 -14
  10. package/src/components/SubscriptionNew.js +20 -8
  11. package/src/components/Subscriptions.js +22 -7
  12. package/src/components/SubscriptionsLoader.js +26 -13
  13. package/src/components/__tests__/NotificationEvent.spec.js +8 -9
  14. package/src/components/__tests__/ShareLinkForm.spec.js +14 -34
  15. package/src/components/__tests__/Subscription.spec.js +18 -27
  16. package/src/components/__tests__/SubscriptionEdit.spec.js +12 -20
  17. package/src/components/__tests__/SubscriptionForm.spec.js +51 -156
  18. package/src/components/__tests__/SubscriptionLoader.spec.js +4 -12
  19. package/src/components/__tests__/SubscriptionNew.spec.js +6 -13
  20. package/src/components/__tests__/Subscriptions.spec.js +26 -38
  21. package/src/components/__tests__/SubscriptionsLoader.spec.js +10 -9
  22. package/src/components/__tests__/__snapshots__/NotificationEvent.spec.js.snap +25 -44
  23. package/src/components/__tests__/__snapshots__/ShareLinkForm.spec.js.snap +6 -6
  24. package/src/components/__tests__/__snapshots__/Subscription.spec.js.snap +144 -75
  25. package/src/components/__tests__/__snapshots__/SubscriptionEdit.spec.js.snap +372 -22
  26. package/src/components/__tests__/__snapshots__/SubscriptionForm.spec.js.snap +22 -22
  27. package/src/components/__tests__/__snapshots__/SubscriptionLoader.spec.js.snap +16 -1
  28. package/src/components/__tests__/__snapshots__/SubscriptionNew.spec.js.snap +373 -16
  29. package/src/components/__tests__/__snapshots__/Subscriptions.spec.js.snap +339 -407
  30. package/src/components/__tests__/__snapshots__/SubscriptionsLoader.spec.js.snap +18 -1
  31. package/src/messages/en.js +0 -2
  32. package/src/messages/es.js +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.44.4] 2022-05-19
4
+
5
+ ### Changed
6
+
7
+ - Use `lowerDeburrTrim` function from `@truedat/core`
8
+
3
9
  ## [4.43.3] 2022-05-04
4
10
 
5
11
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/audit",
3
- "version": "4.44.1",
3
+ "version": "4.44.4",
4
4
  "description": "Truedat Web Audit Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.14.1",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.44.1",
37
+ "@truedat/test": "4.44.4",
38
38
  "babel-jest": "^27.0.6",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -84,8 +84,8 @@
84
84
  ]
85
85
  },
86
86
  "dependencies": {
87
- "@truedat/auth": "4.44.1",
88
- "@truedat/core": "4.44.1",
87
+ "@truedat/auth": "4.44.4",
88
+ "@truedat/core": "4.44.4",
89
89
  "axios": "^0.19.2",
90
90
  "path-to-regexp": "^1.7.0",
91
91
  "prop-types": "^15.7.2",
@@ -105,5 +105,5 @@
105
105
  "react-dom": ">= 16.8.6 < 17",
106
106
  "semantic-ui-react": ">= 0.88.2 < 2.1"
107
107
  },
108
- "gitHead": "20d38381ed4cb6658d1122a4bff08a13fedc2d59"
108
+ "gitHead": "36fb183e1d22181e6a15b3bac2c01b39214eacdb"
109
109
  }
@@ -1,24 +1,28 @@
1
- import { useEffect, useCallback } from "react";
2
- import { useDispatch } from "react-redux";
1
+ import { useEffect } from "react";
3
2
  import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
4
  import { fetchEvents, clearEvents } from "../routines";
5
5
 
6
- export const EventsLoader = ({ resource_id, resource_type }) => {
7
- const dispatch = useDispatch();
8
- const stableDispatch = useCallback(dispatch, []);
6
+ export const EventsLoader = ({
7
+ resource_id,
8
+ resource_type,
9
+ fetchEvents,
10
+ clearEvents,
11
+ }) => {
9
12
  useEffect(() => {
10
- stableDispatch(fetchEvents({ resource_id, resource_type }));
13
+ fetchEvents({ resource_id, resource_type });
11
14
  return () => {
12
- stableDispatch(clearEvents());
15
+ clearEvents();
13
16
  };
14
- // eslint-disable-next-line react-hooks/exhaustive-deps
15
- }, [stableDispatch]);
17
+ }, [fetchEvents, clearEvents, resource_id, resource_type]);
16
18
  return null;
17
19
  };
18
20
 
19
21
  EventsLoader.propTypes = {
20
22
  resource_id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
21
- resource_type: PropTypes.string
23
+ resource_type: PropTypes.string,
24
+ fetchEvents: PropTypes.func,
25
+ clearEvents: PropTypes.func,
22
26
  };
23
27
 
24
- export default EventsLoader;
28
+ export default connect(null, { fetchEvents, clearEvents })(EventsLoader);
@@ -1,4 +1,5 @@
1
1
  import React, { useEffect, useRef, useState } from "react";
2
+ import PropTypes from "prop-types";
2
3
  import { FormattedMessage, useIntl } from "react-intl";
3
4
  import { Label } from "semantic-ui-react";
4
5
  import Moment from "react-moment";
@@ -62,7 +63,10 @@ export const NotificationEvent = ({
62
63
  </h4>
63
64
  <p>{event.name}</p>
64
65
  <Label>
65
- <FormattedMessage id={`subscriptions.events.${event.event}`} />
66
+ <FormattedMessage
67
+ id={`subscriptions.events.${event.event}`}
68
+ defaultMessage={event.event}
69
+ />
66
70
  </Label>
67
71
  <Moment locale={locale} fromNow>
68
72
  {date}
@@ -71,4 +75,11 @@ export const NotificationEvent = ({
71
75
  );
72
76
  };
73
77
 
78
+ NotificationEvent.propTypes = {
79
+ event: PropTypes.object,
80
+ date: PropTypes.instanceOf(Date),
81
+ readMark: PropTypes.bool,
82
+ readNotification: PropTypes.func,
83
+ };
84
+
74
85
  export default NotificationEvent;
@@ -4,7 +4,7 @@ import { Button, Container, Form, Header, Ref } from "semantic-ui-react";
4
4
  import PropTypes from "prop-types";
5
5
  import { useIntl } from "react-intl";
6
6
  import { connect } from "react-redux";
7
- import { lowerDeburr } from "@truedat/core/services/sort";
7
+ import { lowerDeburrTrim } from "@truedat/core/services/sort";
8
8
  import { createNotification } from "../routines";
9
9
  import { getRecipients } from "../selectors";
10
10
 
@@ -16,8 +16,6 @@ const GroupsSearchLoader = React.lazy(() =>
16
16
  import("@truedat/auth/groups/components/GroupsSearchLoader")
17
17
  );
18
18
 
19
- const lowerDeburrTrim = _.flow(_.trim, lowerDeburr);
20
-
21
19
  const MIN_SEARCH_CHARACTERS = 2;
22
20
 
23
21
  export const ShareLinkForm = ({
@@ -127,7 +125,7 @@ export const ShareLinkForm = ({
127
125
  disabled={_.isEmpty(selected) || saving}
128
126
  loading={saving}
129
127
  primary
130
- content={formatMessage({ id: "share.actions.submit" })}
128
+ content={formatMessage({ id: "actions.share" })}
131
129
  />
132
130
  </div>
133
131
  </Form>
@@ -1,7 +1,6 @@
1
1
  import _ from "lodash/fp";
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
- import { useSelector } from "react-redux";
5
4
  import {
6
5
  Header,
7
6
  Grid,
@@ -49,11 +48,13 @@ SubscriptionHeader.propTypes = {
49
48
  subheader: PropTypes.string,
50
49
  };
51
50
 
52
- export const Subscription = ({ templates }) => {
53
- const { subscription, users, subscriptionLoading } = useSelector(
54
- _.pick(["subscription", "subscriptionLoading", "users"])
55
- );
56
- if (_.isEmpty(subscription) || subscriptionLoading) return null;
51
+ export const Subscription = ({
52
+ subscription,
53
+ subscriptionLoading: loading,
54
+ templates,
55
+ users,
56
+ }) => {
57
+ if (_.isEmpty(subscription) || loading) return null;
57
58
 
58
59
  const { type, identifier } = _.getOr({}, "subscriber")(subscription);
59
60
  const subscriber =
@@ -86,26 +87,32 @@ export const Subscription = ({ templates }) => {
86
87
  <Segment>
87
88
  <SubscriptionHeader header={subscriber} subheader={resourceName} />
88
89
  <List size="big" relaxed="very">
90
+ {periodicity ? (
91
+ <List.Item>
92
+ <List.Header>
93
+ <FormattedMessage id="subscriptions.periodicity" />
94
+ </List.Header>
95
+ <List.Description>
96
+ <Label>
97
+ <FormattedMessage
98
+ id={`subscriptions.periodicity.${periodicity}`}
99
+ defaultMessage={periodicity}
100
+ />
101
+ </Label>
102
+ </List.Description>
103
+ </List.Item>
104
+ ) : null}
89
105
  <List.Item>
90
106
  <List.Header>
91
- <FormattedMessage id={"subscriptions.periodicity"} />
92
- </List.Header>
93
- <List.Description>
94
- <Label>
95
- <FormattedMessage
96
- id={`subscriptions.periodicity.${periodicity}`}
97
- />
98
- </Label>
99
- </List.Description>
100
- </List.Item>
101
- <List.Item>
102
- <List.Header>
103
- <FormattedMessage id={"subscriptions.events"} />
107
+ <FormattedMessage id="subscriptions.events" />
104
108
  </List.Header>
105
109
  <List.Description>
106
110
  {events.map((event, idx) => (
107
111
  <Label key={idx}>
108
- <FormattedMessage id={`subscriptions.events.${event}`} />
112
+ <FormattedMessage
113
+ id={`subscriptions.events.${event}`}
114
+ defaultMessage={event}
115
+ />
109
116
  </Label>
110
117
  ))}
111
118
  </List.Description>
@@ -118,7 +125,10 @@ export const Subscription = ({ templates }) => {
118
125
  <List.Description>
119
126
  {status.map((status, idx) => (
120
127
  <Label key={idx}>
121
- <FormattedMessage id={`subscriptions.status.${status}`} />
128
+ <FormattedMessage
129
+ id={`subscriptions.status.${status}`}
130
+ defaultMessage={status}
131
+ />
122
132
  </Label>
123
133
  ))}
124
134
  </List.Description>
@@ -176,11 +186,22 @@ export const Subscription = ({ templates }) => {
176
186
  };
177
187
 
178
188
  Subscription.propTypes = {
189
+ subscription: PropTypes.object,
190
+ subscriptionLoading: PropTypes.bool,
179
191
  templates: PropTypes.array,
192
+ users: PropTypes.array,
180
193
  };
181
194
 
182
- const mapStateToProps = ({ templates }) => ({
195
+ const mapStateToProps = ({
196
+ subscription,
197
+ subscriptionLoading,
198
+ templates,
199
+ users,
200
+ }) => ({
201
+ subscription,
202
+ subscriptionLoading,
183
203
  templates,
204
+ users,
184
205
  });
185
206
 
186
207
  export default connect(mapStateToProps)(Subscription);
@@ -1,31 +1,31 @@
1
1
  import _ from "lodash/fp";
2
2
  import React from "react";
3
+ import PropTypes from "prop-types";
3
4
  import { useIntl } from "react-intl";
4
- import { useSelector, useDispatch } from "react-redux";
5
+ import { connect } from "react-redux";
5
6
  import { Container, Segment, Header } from "semantic-ui-react";
6
7
  import { updateSubscription } from "@truedat/core/routines";
7
8
  import SubscriptionCrumbs from "./SubscriptionCrumbs";
8
9
  import SubscriptionForm from "./SubscriptionForm";
9
10
 
10
- export const SubscriptionEdit = () => {
11
- const { subscription, subscriptionLoading, users } = useSelector(
12
- _.pick(["subscription", "subscriptionLoading", "users"])
13
- );
14
- const dispatch = useDispatch();
11
+ export const SubscriptionEdit = ({
12
+ subscription,
13
+ subscriptionLoading: loading,
14
+ users,
15
+ updateSubscription,
16
+ }) => {
15
17
  const { formatMessage } = useIntl();
16
18
 
17
- if (_.isEmpty(subscription) || subscriptionLoading) return null;
19
+ if (_.isEmpty(subscription) || loading) return null;
18
20
 
19
- const onSubmit = subscriptionChanges =>
20
- dispatch(
21
- updateSubscription({
22
- subscription: {
23
- ...subscriptionChanges,
24
- id: subscription.id
25
- },
26
- redirect: true
27
- })
28
- );
21
+ const onSubmit = (subscriptionChanges) =>
22
+ updateSubscription({
23
+ subscription: {
24
+ ...subscriptionChanges,
25
+ id: subscription.id,
26
+ },
27
+ redirect: true,
28
+ });
29
29
 
30
30
  const { type, identifier } = _.getOr({}, "subscriber")(subscription);
31
31
  const subscriber =
@@ -52,4 +52,19 @@ export const SubscriptionEdit = () => {
52
52
  );
53
53
  };
54
54
 
55
- export default SubscriptionEdit;
55
+ SubscriptionEdit.propTypes = {
56
+ subscription: PropTypes.object,
57
+ subscriptionLoading: PropTypes.bool,
58
+ updateSubscription: PropTypes.func,
59
+ users: PropTypes.array,
60
+ };
61
+
62
+ export const mapStateToProps = ({
63
+ subscription,
64
+ subscriptionLoading,
65
+ users,
66
+ }) => ({ subscription, subscriptionLoading, users });
67
+
68
+ export default connect(mapStateToProps, { updateSubscription })(
69
+ SubscriptionEdit
70
+ );
@@ -396,6 +396,7 @@ export const SubscriptionForm = ({
396
396
  value: periodicity,
397
397
  text: formatMessage({
398
398
  id: `subscriptions.periodicity.${periodicity}`,
399
+ defaultMessage: periodicity,
399
400
  }),
400
401
  }))}
401
402
  />
@@ -427,7 +428,10 @@ export const SubscriptionForm = ({
427
428
  options={eventsForType.map((event, key) => ({
428
429
  key,
429
430
  value: event,
430
- text: formatMessage({ id: `subscriptions.events.${event}` }),
431
+ text: formatMessage({
432
+ id: `subscriptions.events.${event}`,
433
+ defaultMessage: event,
434
+ }),
431
435
  }))}
432
436
  />
433
437
  )}
@@ -483,7 +487,7 @@ export const SubscriptionForm = ({
483
487
  type="submit"
484
488
  loading={isLoading}
485
489
  disabled={disabled}
486
- content={formatMessage({ id: "actions.submit" })}
490
+ content={formatMessage({ id: "actions.save" })}
487
491
  />
488
492
  </div>
489
493
  </Form>
@@ -1,23 +1,22 @@
1
- import _ from "lodash/fp";
2
- import React, { useEffect, useCallback } from "react";
3
- import { useSelector } from "react-redux";
1
+ import React, { useEffect } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
4
  import { useParams } from "react-router-dom";
5
- import { useDispatch } from "react-redux";
6
5
  import { Dimmer, Loader } from "semantic-ui-react";
6
+ import { clearSubscription, fetchSubscription } from "../routines";
7
7
 
8
- import { fetchSubscription, clearSubscription } from "../routines";
9
-
10
- export const SubscriptionLoader = () => {
11
- const loading = useSelector(_.get("subscriptionLoading"));
8
+ export const SubscriptionLoader = ({
9
+ clearSubscription,
10
+ fetchSubscription,
11
+ subscriptionLoading: loading,
12
+ }) => {
12
13
  const { id } = useParams();
13
- const dispatch = useDispatch();
14
- const stableDispatch = useCallback(dispatch, []);
15
14
  useEffect(() => {
16
- stableDispatch(fetchSubscription({ id }));
15
+ fetchSubscription({ id });
17
16
  return () => {
18
- stableDispatch(clearSubscription());
17
+ clearSubscription();
19
18
  };
20
- }, [id, stableDispatch]);
19
+ }, [id, clearSubscription, fetchSubscription]);
21
20
  return loading ? (
22
21
  <Dimmer active inverted>
23
22
  <Loader size="massive" inverted />
@@ -25,4 +24,17 @@ export const SubscriptionLoader = () => {
25
24
  ) : null;
26
25
  };
27
26
 
28
- export default SubscriptionLoader;
27
+ SubscriptionLoader.propTypes = {
28
+ clearSubscription: PropTypes.func,
29
+ fetchSubscription: PropTypes.func,
30
+ subscriptionLoading: PropTypes.bool,
31
+ };
32
+
33
+ export const mapStateToProps = ({ subscriptionLoading }) => ({
34
+ subscriptionLoading,
35
+ });
36
+
37
+ export default connect(mapStateToProps, {
38
+ clearSubscription,
39
+ fetchSubscription,
40
+ })(SubscriptionLoader);
@@ -1,19 +1,20 @@
1
- import _ from "lodash/fp";
2
1
  import React from "react";
2
+ import PropTypes from "prop-types";
3
3
  import { useIntl } from "react-intl";
4
- import { useSelector, useDispatch } from "react-redux";
4
+ import { connect } from "react-redux";
5
5
  import { Container, Segment, Header } from "semantic-ui-react";
6
6
  import { createSubscription } from "@truedat/core/routines";
7
7
  import SubscriptionCrumbs from "./SubscriptionCrumbs";
8
8
  import SubscriptionForm from "./SubscriptionForm";
9
9
 
10
- export const SubscriptionNew = () => {
11
- const creatingSubscription = useSelector(_.get("creatingSubscription"));
12
- const dispatch = useDispatch();
10
+ export const SubscriptionNew = ({
11
+ createSubscription,
12
+ creatingSubscription,
13
+ }) => {
13
14
  const { formatMessage } = useIntl();
14
15
 
15
- const onSubmit = subscription =>
16
- dispatch(createSubscription({ subscription, redirect: true }));
16
+ const onSubmit = (subscription) =>
17
+ createSubscription({ subscription, redirect: true });
17
18
 
18
19
  return (
19
20
  <>
@@ -35,4 +36,15 @@ export const SubscriptionNew = () => {
35
36
  );
36
37
  };
37
38
 
38
- export default SubscriptionNew;
39
+ SubscriptionNew.propTypes = {
40
+ createSubscription: PropTypes.func,
41
+ creatingSubscription: PropTypes.bool,
42
+ };
43
+
44
+ export const mapStateToProps = ({ creatingSubscription }) => ({
45
+ creatingSubscription,
46
+ });
47
+
48
+ export default connect(mapStateToProps, { createSubscription })(
49
+ SubscriptionNew
50
+ );
@@ -1,6 +1,7 @@
1
1
  import _ from "lodash/fp";
2
2
  import React from "react";
3
- import { useSelector } from "react-redux";
3
+ import PropTypes from "prop-types";
4
+ import { connect } from "react-redux";
4
5
  import { useForm, Controller } from "react-hook-form";
5
6
  import { useHistory, Link } from "react-router-dom";
6
7
  import { FormattedMessage } from "react-intl";
@@ -49,7 +50,11 @@ export const SubscriptionsHeader = () => (
49
50
  </Header>
50
51
  );
51
52
 
52
- export const Subscriptions = () => {
53
+ export const Subscriptions = ({
54
+ subscriptions,
55
+ subscriptionsLoading: loading,
56
+ users,
57
+ }) => {
53
58
  const history = useHistory();
54
59
  const { control, watch } = useForm({
55
60
  mode: "all",
@@ -59,10 +64,7 @@ export const Subscriptions = () => {
59
64
  },
60
65
  });
61
66
 
62
- const { subscriptions, subscriptionsLoading, users } = useSelector(
63
- _.pick(["subscriptions", "subscriptionsLoading", "users"])
64
- );
65
- if (subscriptionsLoading) return null;
67
+ if (loading) return null;
66
68
 
67
69
  const usersById = _.keyBy("id")(users);
68
70
  const subscriberIcon = ({ type }) =>
@@ -201,6 +203,7 @@ export const Subscriptions = () => {
201
203
  {periodicity && (
202
204
  <FormattedMessage
203
205
  id={`subscriptions.periodicity.${periodicity}`}
206
+ defaultMessage={periodicity}
204
207
  />
205
208
  )}
206
209
  </Table.Cell>
@@ -213,4 +216,16 @@ export const Subscriptions = () => {
213
216
  );
214
217
  };
215
218
 
216
- export default Subscriptions;
219
+ Subscriptions.propTypes = {
220
+ subscriptions: PropTypes.array,
221
+ subscriptionsLoading: PropTypes.bool,
222
+ users: PropTypes.array,
223
+ };
224
+
225
+ export const mapStateToProps = ({
226
+ subscriptions,
227
+ subscriptionsLoading,
228
+ users,
229
+ }) => ({ subscriptions, subscriptionsLoading, users });
230
+
231
+ export default connect(mapStateToProps)(Subscriptions);
@@ -1,20 +1,20 @@
1
- import _ from "lodash/fp";
2
- import React, { useEffect, useCallback } from "react";
3
- import { useSelector, useDispatch } from "react-redux";
1
+ import React, { useEffect } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
4
  import { Dimmer, Loader } from "semantic-ui-react";
5
+ import { clearSubscriptions, fetchSubscriptions } from "../routines";
5
6
 
6
- import { fetchSubscriptions, clearSubscriptions } from "../routines";
7
-
8
- export const SubscriptionsLoader = () => {
9
- const loading = useSelector(_.get("subscriptionsLoading"));
10
- const dispatch = useDispatch();
11
- const stableDispatch = useCallback(dispatch, []);
7
+ export const SubscriptionsLoader = ({
8
+ clearSubscriptions,
9
+ fetchSubscriptions,
10
+ loading,
11
+ }) => {
12
12
  useEffect(() => {
13
- stableDispatch(fetchSubscriptions());
13
+ fetchSubscriptions();
14
14
  return () => {
15
- stableDispatch(clearSubscriptions());
15
+ clearSubscriptions();
16
16
  };
17
- }, [stableDispatch]);
17
+ }, [clearSubscriptions, fetchSubscriptions]);
18
18
  return loading ? (
19
19
  <Dimmer active inverted>
20
20
  <Loader size="massive" inverted />
@@ -22,4 +22,17 @@ export const SubscriptionsLoader = () => {
22
22
  ) : null;
23
23
  };
24
24
 
25
- export default SubscriptionsLoader;
25
+ SubscriptionsLoader.propTypes = {
26
+ clearSubscriptions: PropTypes.func,
27
+ fetchSubscriptions: PropTypes.func,
28
+ loading: PropTypes.bool,
29
+ };
30
+
31
+ export const mapStateToProps = ({ subscriptionsLoading }) => ({
32
+ loading: subscriptionsLoading,
33
+ });
34
+
35
+ export default connect(mapStateToProps, {
36
+ clearSubscriptions,
37
+ fetchSubscriptions,
38
+ })(SubscriptionsLoader);
@@ -1,21 +1,20 @@
1
1
  import React from "react";
2
- import { intl } from "@truedat/test/intl-stub";
3
- import { shallow } from "enzyme";
4
- import { NotificationEvent } from "../NotificationEvent";
2
+ import { render } from "@truedat/test/render";
3
+ import NotificationEvent from "../NotificationEvent";
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);
5
+ jest.mock("@truedat/core/hooks", () => ({ useOnScreen: jest.fn() }));
9
6
 
10
7
  describe("<NotificationEvent />", () => {
11
8
  it("matches the latest snapshot", () => {
12
9
  const event = {
13
10
  event: "comment_created",
14
- name: "event name"
11
+ name: "event name",
15
12
  };
16
13
  const date = new Date("2020-01-01");
17
14
 
18
- const wrapper = shallow(<NotificationEvent event={event} date={date} />);
19
- expect(wrapper).toMatchSnapshot();
15
+ const { container } = render(
16
+ <NotificationEvent event={event} date={date} />
17
+ );
18
+ expect(container).toMatchSnapshot();
20
19
  });
21
20
  });