diff --git a/src/components/RavenError.test.js b/src/components/RavenError.test.js new file mode 100644 index 0000000..084bf25 --- /dev/null +++ b/src/components/RavenError.test.js @@ -0,0 +1,47 @@ +import React from 'react'; +import { shallow } from 'enzyme'; + +jest.mock('../sentry'); + +import RavenError from './RavenError'; +import { Raven } from '../sentry'; + +const testError = { error: 'test error' }; +const testDetails = { details: 'test details' }; + +describe('RavenError', () => { + test('rendering', () => { + const component = shallow( + + ); + expect(component).toMatchSnapshot(); + }); + + test('captures exception', () => { + shallow( + + ); + expect(Raven.captureException).toHaveBeenCalledWith(testError, testDetails); + }); + + test('error reporting', () => { + Raven.lastEventId.mockReturnValue(1); + const component = shallow( + + ); + const eventObj = { preventDefault: jest.fn() }; + component.find('a').simulate('click', eventObj); + + expect(eventObj.preventDefault).toHaveBeenCalled(); + expect(Raven.showReportDialog).toHaveBeenCalled(); + }); +}); diff --git a/src/components/__snapshots__/RavenError.test.js.snap b/src/components/__snapshots__/RavenError.test.js.snap new file mode 100644 index 0000000..bbcb7da --- /dev/null +++ b/src/components/__snapshots__/RavenError.test.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RavenError 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 + + . +