Fix Raven tests

This commit is contained in:
ziajka 2018-04-05 15:45:21 +02:00
parent 6f0de11bda
commit f893714d69
2 changed files with 8 additions and 3 deletions

View File

@ -19,6 +19,6 @@
</main>
<footer class="footer mat-app-background">
GNS3 Web UI demo &copy; 2017
GNS3 Web UI demo &copy; 2018
</footer>

View File

@ -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();
});