mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-03-01 04:16:32 +00:00
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { TestBed } from '@angular/core/testing';
|
|
import { PersistenceService } from "angular-persistence";
|
|
|
|
import * as Raven from 'raven-js';
|
|
|
|
import { SettingsService } from "./shared/services/settings.service";
|
|
import { RavenErrorHandler } from "./raven-error-handler";
|
|
import { environment } from "../environments/environment";
|
|
|
|
|
|
describe('RavenErrorHandler', () => {
|
|
let handler: RavenErrorHandler;
|
|
let settingsService: SettingsService;
|
|
const inProductionOriginal = environment.production;
|
|
|
|
beforeEach(() => {
|
|
TestBed.configureTestingModule({
|
|
providers: [SettingsService, PersistenceService, RavenErrorHandler]
|
|
});
|
|
|
|
settingsService = TestBed.get(SettingsService);
|
|
handler = TestBed.get(RavenErrorHandler);
|
|
});
|
|
|
|
afterEach(() => {
|
|
environment.production = inProductionOriginal;
|
|
});
|
|
|
|
it('should create', () => {
|
|
expect(handler).toBeTruthy();
|
|
});
|
|
|
|
it('should handle error', () => {
|
|
settingsService.set('crash_reports', true);
|
|
const error = new Error("My error");
|
|
const captureException = spyOn(Raven, 'captureException');
|
|
environment.production = true;
|
|
handler.handleError(error);
|
|
expect(captureException).toHaveBeenCalledWith(error);
|
|
});
|
|
|
|
it('should not handle when not in production', () => {
|
|
const captureException = spyOn(Raven, 'captureException');
|
|
environment.production = false;
|
|
handler.handleError(new Error("My error"));
|
|
expect(captureException).not.toHaveBeenCalled();
|
|
});
|
|
});
|