Browse Source

Fix failing TravisCI tests #106 (#107)

* add alert srv mock
* silent remove in test
master
Alexey Velikiy 6 years ago committed by GitHub
parent
commit
696bc59db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      .travis.yml
  2. 21
      __mocks__/grafana/app/core/services/alert_srv.ts
  3. 3
      src/services/analytic_service.ts
  4. 2
      tests/analytic_controller.jest.ts
  5. 3
      tests/setup_tests.ts

8
.travis.yml

@ -1,12 +1,8 @@
language: node_js
node_js:
- "8"
before_script:
before_script:
- npm install
script: npm test
notifications:
email: false
email: false

21
__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 {}
}

3
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
) {

2
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');
}

3
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

Loading…
Cancel
Save