From 79191c0fd746208497d97ad747cbfacbe9164fde Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Thu, 15 Feb 2018 17:33:43 -0500 Subject: [PATCH] Improving coverage in RavenError tests --- src/components/RavenError/test.js | 41 ++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/components/RavenError/test.js b/src/components/RavenError/test.js index 37996bb..fafdbe9 100644 --- a/src/components/RavenError/test.js +++ b/src/components/RavenError/test.js @@ -31,18 +31,35 @@ describe('RavenError', () => { 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); + describe('error reporting', () => { + test('clicking to fill out a report when an event has been logged', () => { + 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(); + expect(eventObj.preventDefault).toHaveBeenCalled(); + expect(Raven.showReportDialog).toHaveBeenCalled(); + }); + + test('clicking to fill out a report when an event has not been logged', () => { + Raven.lastEventId.mockReturnValue(false); + const component = shallow( + + ); + const eventObj = { preventDefault: jest.fn() }; + component.find('a').simulate('click', eventObj); + + expect(eventObj.preventDefault).toHaveBeenCalled(); + expect(Raven.showReportDialog).not.toHaveBeenCalled(); + }); }); });