From f893714d6922331a27a70344e1ec6a936edc0052 Mon Sep 17 00:00:00 2001 From: ziajka Date: Thu, 5 Apr 2018 15:45:21 +0200 Subject: [PATCH] Fix Raven tests --- src/app/default-layout/default-layout.component.html | 2 +- src/app/raven-error-handler.spec.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/default-layout/default-layout.component.html b/src/app/default-layout/default-layout.component.html index f6b736d6..cfe2f4e8 100644 --- a/src/app/default-layout/default-layout.component.html +++ b/src/app/default-layout/default-layout.component.html @@ -19,6 +19,6 @@ diff --git a/src/app/raven-error-handler.spec.ts b/src/app/raven-error-handler.spec.ts index 38225f3b..9c295851 100644 --- a/src/app/raven-error-handler.spec.ts +++ b/src/app/raven-error-handler.spec.ts @@ -11,6 +11,7 @@ import { environment } from "../environments/environment"; describe('RavenErrorHandler', () => { let handler: RavenErrorHandler; let settingsService: SettingsService; + const inProductionOriginal = environment.production; beforeEach(() => { TestBed.configureTestingModule({ @@ -21,6 +22,10 @@ describe('RavenErrorHandler', () => { handler = TestBed.get(RavenErrorHandler); }); + afterEach(() => { + environment.production = inProductionOriginal; + }); + it('should create', () => { expect(handler).toBeTruthy(); }); @@ -29,14 +34,14 @@ describe('RavenErrorHandler', () => { settingsService.set('crash_reports', true); const error = new Error("My error"); const captureException = spyOn(Raven, 'captureException'); - spyOn(environment, 'production').and.returnValue(true); + environment.production = true; handler.handleError(error); expect(captureException).toHaveBeenCalledWith(error); }); it('should not handle when not in production', () => { const captureException = spyOn(Raven, 'captureException'); - spyOnProperty(environment, 'production').and.returnValue(false); + environment.production = false; handler.handleError(new Error("My error")); expect(captureException).not.toHaveBeenCalled(); });