diff --git a/.travis.yml b/.travis.yml index 360ecf9..29c28ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,8 @@ language: node_js - node_js: - "8" - - before_script: +before_script: - npm install - script: npm test - notifications: - email: false \ No newline at end of file + email: false diff --git a/__mocks__/grafana/app/core/services/alert_srv.ts b/__mocks__/grafana/app/core/services/alert_srv.ts new file mode 100644 index 0000000..fb541b0 --- /dev/null +++ b/__mocks__/grafana/app/core/services/alert_srv.ts @@ -0,0 +1,21 @@ +export class AlertSrv { + private $timeout; + private $sce; + private $rootScope; + private $modal; + list: any[]; + /** @ngInject */ + constructor($timeout: any, $sce: any, $rootScope: any, $modal: any) {} + init(): void {} + set(title: any, text: any, severity: any, timeout: any): { + title: any; + text: any; + severity: any; + } + { + return { title: '', text: '', severity: '' } + } + clear(alert: any): void {} + clearAll(): void {} + showConfirmModal(payload: any): void {} +} diff --git a/src/services/analytic_service.ts b/src/services/analytic_service.ts index 6b11b27..79228ce 100644 --- a/src/services/analytic_service.ts +++ b/src/services/analytic_service.ts @@ -12,7 +12,8 @@ export class AnalyticService { private _isUp = false; constructor( - private _backendURL: string, private $http, + private _backendURL: string, + private $http, private _backendSrv: BackendSrv, private _alertSrv: AlertSrv ) { diff --git a/tests/analytic_controller.jest.ts b/tests/analytic_controller.jest.ts index 3f6e6c0..fc8afbd 100644 --- a/tests/analytic_controller.jest.ts +++ b/tests/analytic_controller.jest.ts @@ -19,7 +19,7 @@ describe('AnalyticController', function () { }); it('should remove analytic unit with right id', async function () { - await analyticController.removeAnalyticUnit('2'); + await analyticController.removeAnalyticUnit('2', true); for (let analyticUnit of analyticController.analyticUnits) { expect(analyticUnit.id).not.toBe('2'); } diff --git a/tests/setup_tests.ts b/tests/setup_tests.ts index f80a704..6c335c1 100644 --- a/tests/setup_tests.ts +++ b/tests/setup_tests.ts @@ -5,6 +5,7 @@ import { MetricExpanded } from '../src/models/metric'; import { DatasourceRequest } from '../src/models/datasource'; import { BackendSrv } from 'grafana/app/core/services/backend_srv'; +import { AlertSrv } from 'grafana/app/core/services/alert_srv'; import { Emitter } from 'grafana/app/core/utils/emitter'; @@ -13,7 +14,7 @@ import { Emitter } from 'grafana/app/core/utils/emitter'; var id = 0; -const analyticService = new AnalyticService('', new BackendSrv({}, {}, {}, {}, {})); +const analyticService = new AnalyticService('', {} , new BackendSrv({}, {}, {}, {}, {}), new AlertSrv()); analyticService.postNewItem = async function ( metric: MetricExpanded, datasourceRequest: DatasourceRequest, newItem: AnalyticUnit, panelId: number