Browse Source

Travis CI build failing #152 (#153)

master
sanke1 6 years ago committed by rozetko
parent
commit
605043da48
  1. 1
      __mocks__/grafana/app/core/core.ts
  2. 6
      tests/analytic_controller.jest.ts
  3. 12
      tests/setup_tests.ts

1
__mocks__/grafana/app/core/core.ts

@ -0,0 +1 @@
export {};

6
tests/analytic_controller.jest.ts

@ -10,7 +10,7 @@ describe('AnalyticController', function () {
for (let color of ANALYTIC_UNIT_COLORS) { for (let color of ANALYTIC_UNIT_COLORS) {
analyticController.createNew(); analyticController.createNew();
expect(analyticController.newAnalyticUnit.color).toBe(color); expect(analyticController.newAnalyticUnit.color).toBe(color);
await analyticController.saveNew({} as MetricExpanded, {} as DatasourceRequest, 1); await analyticController.saveNew({} as MetricExpanded, {} as DatasourceRequest, '');
} }
}); });
@ -28,7 +28,7 @@ describe('AnalyticController', function () {
it('should set different color to newly created Analytic Unit, afer NOT last AU was deleted', async function() { it('should set different color to newly created Analytic Unit, afer NOT last AU was deleted', async function() {
let auArray = analyticController.analyticUnits; let auArray = analyticController.analyticUnits;
analyticController.createNew(); analyticController.createNew();
await analyticController.saveNew({} as MetricExpanded, {} as DatasourceRequest, 1); await analyticController.saveNew({} as MetricExpanded, {} as DatasourceRequest, '');
expect(auArray[auArray.length - 2].panelObject.color).not.toBe(auArray[auArray.length - 1].panelObject.color); expect(auArray[auArray.length - 2].panelObject.color).not.toBe(auArray[auArray.length - 1].panelObject.color);
}); });
@ -36,7 +36,7 @@ describe('AnalyticController', function () {
let auArray = analyticController.analyticUnits; let auArray = analyticController.analyticUnits;
auArray.splice(-1, 1); auArray.splice(-1, 1);
analyticController.createNew(); analyticController.createNew();
await analyticController.saveNew({} as MetricExpanded, {} as DatasourceRequest, 1); await analyticController.saveNew({} as MetricExpanded, {} as DatasourceRequest, '');
expect(auArray[auArray.length - 2].panelObject.color).not.toBe(auArray[auArray.length - 1].panelObject.color); expect(auArray[auArray.length - 2].panelObject.color).not.toBe(auArray[auArray.length - 1].panelObject.color);
}); });

12
tests/setup_tests.ts

@ -4,8 +4,6 @@ import { AnalyticService } from '../src/services/analytic_service';
import { MetricExpanded } from '../src/models/metric'; import { MetricExpanded } from '../src/models/metric';
import { DatasourceRequest } from '../src/models/datasource'; 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'; import { Emitter } from 'grafana/app/core/utils/emitter';
@ -14,10 +12,12 @@ import { Emitter } from 'grafana/app/core/utils/emitter';
var id = 0; var id = 0;
const analyticService = new AnalyticService('', {} , new BackendSrv({}, {}, {}, {}, {}), new AlertSrv()); function $http() {
analyticService.postNewItem = async function ( return { data: { pattern: [], thresholds: [] } };
metric: MetricExpanded, datasourceRequest: DatasourceRequest, }
newItem: AnalyticUnit, panelId: number
const analyticService = new AnalyticService('', $http);
analyticService.postNewItem = async function (newItem: AnalyticUnit, metric: MetricExpanded, datasource: DatasourceRequest, panelUrl: string
): Promise<AnalyticUnitId> { ): Promise<AnalyticUnitId> {
id++; id++;
return Promise.resolve(id.toString()); return Promise.resolve(id.toString());

Loading…
Cancel
Save