Skip to content

Commit

Permalink
improved field tests on the onlyAggregatable option
Browse files Browse the repository at this point in the history
  • Loading branch information
scampi committed Nov 18, 2016
1 parent d697f11 commit c2249e5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/ui/public/agg_types/__tests__/param_types/_field.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import expect from 'expect.js';
import { reject } from 'lodash';
import ngMock from 'ng_mock';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base';
Expand Down Expand Up @@ -29,20 +30,21 @@ describe('Field', function () {
});

describe('getFieldOptions', function () {
it('should return only aggregatable fields', function () {
it('should return only aggregatable fields by default', function () {
const aggParam = new FieldAggParam({
name: 'field'
});

const fields = aggParam.getFieldOptions({
getIndexPattern: () => indexPattern
});
expect(fields).to.not.have.length(0);
for (let field of fields) {
expect(field.aggregatable).to.be(true);
}
});

it('should return all fields', function () {
it('should return all fields if onlyAggregatable is false', function () {
const aggParam = new FieldAggParam({
name: 'field'
});
Expand All @@ -52,13 +54,8 @@ describe('Field', function () {
const fields = aggParam.getFieldOptions({
getIndexPattern: () => indexPattern
});
let nAggregatable = 0;
for (let field of fields) {
if (field.aggregatable) {
nAggregatable++;
}
}
expect(fields.length - nAggregatable > 0).to.be(true);
const nonAggregatableFields = reject(fields, 'aggregatable');
expect(nonAggregatableFields).to.not.be.empty();
});
});
});

0 comments on commit c2249e5

Please sign in to comment.