Commit 56628996 by Marcus Efraimsson Committed by GitHub

Merge pull request #12280 from dehrax/12224-elastic-response

karma to jest: 6 test files
parents 01074911 dbbd6b9b
......@@ -18,9 +18,9 @@ describe('ThresholdMapper', () => {
};
var updated = ThresholdMapper.alertToGraphThresholds(panel);
expect(updated).to.be(true);
expect(panel.thresholds[0].op).to.be('gt');
expect(panel.thresholds[0].value).to.be(100);
expect(updated).toBe(true);
expect(panel.thresholds[0].op).toBe('gt');
expect(panel.thresholds[0].value).toBe(100);
});
});
......@@ -39,12 +39,12 @@ describe('ThresholdMapper', () => {
};
var updated = ThresholdMapper.alertToGraphThresholds(panel);
expect(updated).to.be(true);
expect(panel.thresholds[0].op).to.be('lt');
expect(panel.thresholds[0].value).to.be(100);
expect(updated).toBe(true);
expect(panel.thresholds[0].op).toBe('lt');
expect(panel.thresholds[0].value).toBe(100);
expect(panel.thresholds[1].op).to.be('gt');
expect(panel.thresholds[1].value).to.be(200);
expect(panel.thresholds[1].op).toBe('gt');
expect(panel.thresholds[1].value).toBe(200);
});
});
......@@ -63,12 +63,12 @@ describe('ThresholdMapper', () => {
};
var updated = ThresholdMapper.alertToGraphThresholds(panel);
expect(updated).to.be(true);
expect(panel.thresholds[0].op).to.be('gt');
expect(panel.thresholds[0].value).to.be(100);
expect(updated).toBe(true);
expect(panel.thresholds[0].op).toBe('gt');
expect(panel.thresholds[0].value).toBe(100);
expect(panel.thresholds[1].op).to.be('lt');
expect(panel.thresholds[1].value).to.be(200);
expect(panel.thresholds[1].op).toBe('lt');
expect(panel.thresholds[1].value).toBe(200);
});
});
});
///<amd-dependency path="test/specs/helpers" name="helpers" />
import { describe, it, expect } from 'test/lib/common';
import moment from 'moment';
import { IndexPattern } from '../index_pattern';
describe('IndexPattern', function() {
describe('when getting index for today', function() {
it('should return correct index name', function() {
describe('IndexPattern', () => {
describe('when getting index for today', () => {
test('should return correct index name', () => {
var pattern = new IndexPattern('[asd-]YYYY.MM.DD', 'Daily');
var expected = 'asd-' + moment.utc().format('YYYY.MM.DD');
expect(pattern.getIndexForToday()).to.be(expected);
expect(pattern.getIndexForToday()).toBe(expected);
});
});
describe('when getting index list for time range', function() {
describe('no interval', function() {
it('should return correct index', function() {
describe('when getting index list for time range', () => {
describe('no interval', () => {
test('should return correct index', () => {
var pattern = new IndexPattern('my-metrics', null);
var from = new Date(2015, 4, 30, 1, 2, 3);
var to = new Date(2015, 5, 1, 12, 5, 6);
expect(pattern.getIndexList(from, to)).to.eql('my-metrics');
expect(pattern.getIndexList(from, to)).toEqual('my-metrics');
});
});
describe('daily', function() {
it('should return correct index list', function() {
describe('daily', () => {
test('should return correct index list', () => {
var pattern = new IndexPattern('[asd-]YYYY.MM.DD', 'Daily');
var from = new Date(1432940523000);
var to = new Date(1433153106000);
var expected = ['asd-2015.05.29', 'asd-2015.05.30', 'asd-2015.05.31', 'asd-2015.06.01'];
expect(pattern.getIndexList(from, to)).to.eql(expected);
expect(pattern.getIndexList(from, to)).toEqual(expected);
});
});
});
......
import { describe, it, expect } from 'test/lib/common';
import * as queryDef from '../query_def';
describe('ElasticQueryDef', function() {
describe('getPipelineAggOptions', function() {
describe('with zero targets', function() {
describe('ElasticQueryDef', () => {
describe('getPipelineAggOptions', () => {
describe('with zero targets', () => {
var response = queryDef.getPipelineAggOptions([]);
it('should return zero', function() {
expect(response.length).to.be(0);
test('should return zero', () => {
expect(response.length).toBe(0);
});
});
describe('with count and sum targets', function() {
describe('with count and sum targets', () => {
var targets = {
metrics: [{ type: 'count', field: '@value' }, { type: 'sum', field: '@value' }],
};
var response = queryDef.getPipelineAggOptions(targets);
it('should return zero', function() {
expect(response.length).to.be(2);
test('should return zero', () => {
expect(response.length).toBe(2);
});
});
describe('with count and moving average targets', function() {
describe('with count and moving average targets', () => {
var targets = {
metrics: [{ type: 'count', field: '@value' }, { type: 'moving_avg', field: '@value' }],
};
var response = queryDef.getPipelineAggOptions(targets);
it('should return one', function() {
expect(response.length).to.be(1);
test('should return one', () => {
expect(response.length).toBe(1);
});
});
describe('with derivatives targets', function() {
describe('with derivatives targets', () => {
var targets = {
metrics: [{ type: 'derivative', field: '@value' }],
};
var response = queryDef.getPipelineAggOptions(targets);
it('should return zero', function() {
expect(response.length).to.be(0);
test('should return zero', () => {
expect(response.length).toBe(0);
});
});
});
describe('isPipelineMetric', function() {
describe('moving_avg', function() {
describe('isPipelineMetric', () => {
describe('moving_avg', () => {
var result = queryDef.isPipelineAgg('moving_avg');
it('is pipe line metric', function() {
expect(result).to.be(true);
test('is pipe line metric', () => {
expect(result).toBe(true);
});
});
describe('count', function() {
describe('count', () => {
var result = queryDef.isPipelineAgg('count');
it('is not pipe line metric', function() {
expect(result).to.be(false);
test('is not pipe line metric', () => {
expect(result).toBe(false);
});
});
});
describe('pipeline aggs depending on esverison', function() {
describe('using esversion undefined', function() {
it('should not get pipeline aggs', function() {
expect(queryDef.getMetricAggTypes(undefined).length).to.be(9);
describe('pipeline aggs depending on esverison', () => {
describe('using esversion undefined', () => {
test('should not get pipeline aggs', () => {
expect(queryDef.getMetricAggTypes(undefined).length).toBe(9);
});
});
describe('using esversion 1', function() {
it('should not get pipeline aggs', function() {
expect(queryDef.getMetricAggTypes(1).length).to.be(9);
describe('using esversion 1', () => {
test('should not get pipeline aggs', () => {
expect(queryDef.getMetricAggTypes(1).length).toBe(9);
});
});
describe('using esversion 2', function() {
it('should get pipeline aggs', function() {
expect(queryDef.getMetricAggTypes(2).length).to.be(11);
describe('using esversion 2', () => {
test('should get pipeline aggs', () => {
expect(queryDef.getMetricAggTypes(2).length).toBe(11);
});
});
describe('using esversion 5', function() {
it('should get pipeline aggs', function() {
expect(queryDef.getMetricAggTypes(5).length).to.be(11);
describe('using esversion 5', () => {
test('should get pipeline aggs', () => {
expect(queryDef.getMetricAggTypes(5).length).toBe(11);
});
});
});
......
import { describe, it, expect } from 'test/lib/common';
import { InfluxQueryBuilder } from '../query_builder';
describe('InfluxQueryBuilder', function() {
......
import { describe, it, expect } from '../../../../../test/lib/common';
import angular from 'angular';
import TimeSeries from 'app/core/time_series2';
import { ThresholdManager } from '../threshold_manager';
......@@ -38,16 +36,16 @@ describe('ThresholdManager', function() {
it('should add fill for threshold with fill: true', function() {
var markings = ctx.options.grid.markings;
expect(markings[0].yaxis.from).to.be(300);
expect(markings[0].yaxis.to).to.be(Infinity);
expect(markings[0].color).to.be('rgba(234, 112, 112, 0.12)');
expect(markings[0].yaxis.from).toBe(300);
expect(markings[0].yaxis.to).toBe(Infinity);
expect(markings[0].color).toBe('rgba(234, 112, 112, 0.12)');
});
it('should add line', function() {
var markings = ctx.options.grid.markings;
expect(markings[1].yaxis.from).to.be(300);
expect(markings[1].yaxis.to).to.be(300);
expect(markings[1].color).to.be('rgba(237, 46, 24, 0.60)');
expect(markings[1].yaxis.from).toBe(300);
expect(markings[1].yaxis.to).toBe(300);
expect(markings[1].color).toBe('rgba(237, 46, 24, 0.60)');
});
});
......@@ -59,14 +57,14 @@ describe('ThresholdManager', function() {
it('should add fill for first thresholds to next threshold', function() {
var markings = ctx.options.grid.markings;
expect(markings[0].yaxis.from).to.be(200);
expect(markings[0].yaxis.to).to.be(300);
expect(markings[0].yaxis.from).toBe(200);
expect(markings[0].yaxis.to).toBe(300);
});
it('should add fill for last thresholds to infinity', function() {
var markings = ctx.options.grid.markings;
expect(markings[1].yaxis.from).to.be(300);
expect(markings[1].yaxis.to).to.be(Infinity);
expect(markings[1].yaxis.from).toBe(300);
expect(markings[1].yaxis.to).toBe(Infinity);
});
});
......@@ -78,14 +76,14 @@ describe('ThresholdManager', function() {
it('should add fill for first thresholds to next threshold', function() {
var markings = ctx.options.grid.markings;
expect(markings[0].yaxis.from).to.be(300);
expect(markings[0].yaxis.to).to.be(200);
expect(markings[0].yaxis.from).toBe(300);
expect(markings[0].yaxis.to).toBe(200);
});
it('should add fill for last thresholds to itself', function() {
var markings = ctx.options.grid.markings;
expect(markings[1].yaxis.from).to.be(200);
expect(markings[1].yaxis.to).to.be(200);
expect(markings[1].yaxis.from).toBe(200);
expect(markings[1].yaxis.to).toBe(200);
});
});
......@@ -97,14 +95,14 @@ describe('ThresholdManager', function() {
it('should add fill for first thresholds to next threshold', function() {
var markings = ctx.options.grid.markings;
expect(markings[0].yaxis.from).to.be(300);
expect(markings[0].yaxis.to).to.be(Infinity);
expect(markings[0].yaxis.from).toBe(300);
expect(markings[0].yaxis.to).toBe(Infinity);
});
it('should add fill for last thresholds to itself', function() {
var markings = ctx.options.grid.markings;
expect(markings[1].yaxis.from).to.be(200);
expect(markings[1].yaxis.to).to.be(-Infinity);
expect(markings[1].yaxis.from).toBe(200);
expect(markings[1].yaxis.to).toBe(-Infinity);
});
});
......@@ -130,12 +128,12 @@ describe('ThresholdManager', function() {
it('should add first threshold for left axis', function() {
var markings = ctx.options.grid.markings;
expect(markings[0].yaxis.from).to.be(100);
expect(markings[0].yaxis.from).toBe(100);
});
it('should add second threshold for right axis', function() {
var markings = ctx.options.grid.markings;
expect(markings[1].y2axis.from).to.be(200);
expect(markings[1].y2axis.from).toBe(200);
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment