diff --git a/src/components/SentryError/__snapshots__/test.js.snap b/src/components/SentryError/__snapshots__/test.js.snap
index d967bff..bd27abf 100644
--- a/src/components/SentryError/__snapshots__/test.js.snap
+++ b/src/components/SentryError/__snapshots__/test.js.snap
@@ -1,21 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SentryError rendering 1`] = `
-
-
-
- This error has been logged. You may also
-
+
+
+
- fill out a report
-
- .
-
-
-
+ This error has been logged. You may also
+
+ fill out a report
+
+ .
+
+
+
+
`;
diff --git a/src/components/SentryError/index.js b/src/components/SentryError/index.js
index f78f7ad..e0c1d94 100644
--- a/src/components/SentryError/index.js
+++ b/src/components/SentryError/index.js
@@ -16,7 +16,9 @@ const reportError = event => {
export const SentryError = ({ t }) => (
- This error has been logged. You may also This error has been logged. You may also fill out a report.
diff --git a/src/components/SentryError/test.js b/src/components/SentryError/test.js
index 1b82779..dfb1641 100644
--- a/src/components/SentryError/test.js
+++ b/src/components/SentryError/test.js
@@ -1,7 +1,10 @@
jest.mock('@sentry/browser');
+jest.mock('components/Message', () =>
+ require('__mocks__/component-mock')('components/Message'));
+
import React from 'react';
-import { shallow } from 'enzyme';
+import { render, fireEvent } from 'react-testing-library';
import * as Sentry from '@sentry/browser';
import { mockT } from 'i18n';
@@ -9,34 +12,36 @@ import { SentryError } from 'components/SentryError';
describe('SentryError', () => {
test('rendering', () => {
- const component = shallow(
+ const { asFragment } = render(
);
- expect(component).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
describe('error reporting', () => {
test('fill out a report when an event has been logged', () => {
Sentry.lastEventId.mockReturnValue(1);
- const component = shallow(
+ const { getByTestId } = render(
);
- const eventObj = { preventDefault: jest.fn() };
- component.find('a').simulate('click', eventObj);
+ const event = new MouseEvent('click', { bubbles: true });
+ jest.spyOn(event, 'preventDefault');
+ fireEvent(getByTestId('error-report'), event);
- expect(eventObj.preventDefault).toHaveBeenCalled();
+ expect(event.preventDefault).toHaveBeenCalled();
expect(Sentry.showReportDialog).toHaveBeenCalled();
});
test('fill out a report when an event has not been logged', () => {
Sentry.lastEventId.mockReturnValue(false);
- const component = shallow(
+ const { getByTestId } = render(
);
- const eventObj = { preventDefault: jest.fn() };
- component.find('a').simulate('click', eventObj);
+ const event = new MouseEvent('click', { bubbles: true });
+ jest.spyOn(event, 'preventDefault');
+ fireEvent(getByTestId('error-report'), event);
- expect(eventObj.preventDefault).toHaveBeenCalled();
+ expect(event.preventDefault).toHaveBeenCalled();
expect(Sentry.showReportDialog).not.toHaveBeenCalled();
});
});