Skip to content

Commit

Permalink
[aggTypes/paramTypes] naming cleanup (#14020)
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger authored Sep 18, 2017
1 parent 93a565c commit 199e5c3
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 156 deletions.
46 changes: 23 additions & 23 deletions src/ui/public/agg_types/__tests__/agg_params.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import ngMock from 'ng_mock';
import expect from 'expect.js';
import { AggTypesAggParamsProvider } from 'ui/agg_types/agg_params';
import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base';
import { AggTypesParamTypesFieldProvider } from 'ui/agg_types/param_types/field';
import { AggTypesParamTypesOptionedProvider } from 'ui/agg_types/param_types/optioned';
import { AggTypesParamTypesRegexProvider } from 'ui/agg_types/param_types/regex';
import { BaseParamTypeProvider } from '../param_types/base';
import { FieldParamTypeProvider } from '../param_types/field';
import { OptionedParamTypeProvider } from '../param_types/optioned';
import { RegexParamTypeProvider } from '../param_types/regex';

describe('AggParams class', function () {

let AggParams;
let BaseAggParam;
let FieldAggParam;
let OptionedAggParam;
let RegexAggParam;
let BaseParamType;
let FieldParamType;
let OptionedParamType;
let RegexParamType;

beforeEach(ngMock.module('kibana'));
// stub out the param classes before we get the AggParams
beforeEach(ngMock.inject(require('./utils/_stub_agg_params')));
// fetch out deps
beforeEach(ngMock.inject(function (Private) {
AggParams = Private(AggTypesAggParamsProvider);
BaseAggParam = Private(AggTypesParamTypesBaseProvider);
FieldAggParam = Private(AggTypesParamTypesFieldProvider);
OptionedAggParam = Private(AggTypesParamTypesOptionedProvider);
RegexAggParam = Private(AggTypesParamTypesRegexProvider);
BaseParamType = Private(BaseParamTypeProvider);
FieldParamType = Private(FieldParamTypeProvider);
OptionedParamType = Private(OptionedParamTypeProvider);
RegexParamType = Private(RegexParamTypeProvider);
}));

describe('constructor args', function () {
Expand All @@ -41,17 +41,17 @@ describe('AggParams class', function () {
});

describe('AggParam creation', function () {
it('Uses the FieldAggParam class for params with the name "field"', function () {
it('Uses the FieldParamType class for params with the name "field"', function () {
const params = [
{ name: 'field' }
];
const aggParams = new AggParams(params);

expect(aggParams).to.have.length(params.length);
expect(aggParams[0]).to.be.a(FieldAggParam);
expect(aggParams[0]).to.be.a(FieldParamType);
});

it('Uses the OptionedAggParam class for params of type "optioned"', function () {
it('Uses the OptionedParamType class for params of type "optioned"', function () {
const params = [
{
name: 'interval',
Expand All @@ -61,10 +61,10 @@ describe('AggParams class', function () {
const aggParams = new AggParams(params);

expect(aggParams).to.have.length(params.length);
expect(aggParams[0]).to.be.a(OptionedAggParam);
expect(aggParams[0]).to.be.a(OptionedParamType);
});

it('Uses the RegexAggParam class for params of type "regex"', function () {
it('Uses the RegexParamType class for params of type "regex"', function () {
const params = [
{
name: 'exclude',
Expand All @@ -74,10 +74,10 @@ describe('AggParams class', function () {
const aggParams = new AggParams(params);

expect(aggParams).to.have.length(params.length);
expect(aggParams[0]).to.be.a(RegexAggParam);
expect(aggParams[0]).to.be.a(RegexParamType);
});

it('Always converts the params to a BaseAggParam', function () {
it('Always converts the params to a BaseParamType', function () {
const params = [
{
name: 'height',
Expand All @@ -94,13 +94,13 @@ describe('AggParams class', function () {
];
const aggParams = new AggParams(params);

expect(BaseAggParam).to.have.property('callCount', params.length);
expect(FieldAggParam).to.have.property('callCount', 0);
expect(OptionedAggParam).to.have.property('callCount', 0);
expect(BaseParamType).to.have.property('callCount', params.length);
expect(FieldParamType).to.have.property('callCount', 0);
expect(OptionedParamType).to.have.property('callCount', 0);

expect(aggParams).to.have.length(params.length);
aggParams.forEach(function (aggParam) {
expect(aggParam).to.be.a(BaseAggParam);
expect(aggParam).to.be.a(BaseParamType);
});
});
});
Expand Down
22 changes: 11 additions & 11 deletions src/ui/public/agg_types/__tests__/param_types/_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ 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';
import { AggTypesParamTypesFieldProvider } from 'ui/agg_types/param_types/field';
import { BaseParamTypeProvider } from '../../param_types/base';
import { FieldParamTypeProvider } from '../../param_types/field';

describe('Field', function () {

let BaseAggParam;
let FieldAggParam;
let BaseParamType;
let FieldParamType;
let indexPattern;

beforeEach(ngMock.module('kibana'));
// fetch out deps
beforeEach(ngMock.inject(function (Private) {
BaseAggParam = Private(AggTypesParamTypesBaseProvider);
FieldAggParam = Private(AggTypesParamTypesFieldProvider);
BaseParamType = Private(BaseParamTypeProvider);
FieldParamType = Private(FieldParamTypeProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
}));

describe('constructor', function () {
it('it is an instance of BaseAggParam', function () {
const aggParam = new FieldAggParam({
it('it is an instance of BaseParamType', function () {
const aggParam = new FieldParamType({
name: 'field'
});

expect(aggParam).to.be.a(BaseAggParam);
expect(aggParam).to.be.a(BaseParamType);
});
});

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

Expand All @@ -45,7 +45,7 @@ describe('Field', function () {
});

it('should return all fields if onlyAggregatable is false', function () {
const aggParam = new FieldAggParam({
const aggParam = new FieldParamType({
name: 'field'
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base';
import { AggTypesParamTypesRawJsonProvider } from 'ui/agg_types/param_types/raw_json';
import { BaseParamTypeProvider } from '../../param_types/base';
import { JsonParamTypeProvider } from '../../param_types/json';

// eslint-disable-next-line kibana-custom/no-default-export
export default describe('JSON', function () {
const paramName = 'json_test';
let BaseAggParam;
let JsonAggParam;
let BaseParamType;
let JsonParamType;
let aggParam;
let aggConfig;
let output;

function initAggParam(config) {
function initParamType(config) {
config = config || {};
const defaults = {
name: paramName,
type: 'json'
};

aggParam = new JsonAggParam(_.defaults(config, defaults));
aggParam = new JsonParamType(_.defaults(config, defaults));
}

beforeEach(ngMock.module('kibana'));
Expand All @@ -30,15 +30,15 @@ export default describe('JSON', function () {
aggConfig = { params: {} };
output = { params: {} };

BaseAggParam = Private(AggTypesParamTypesBaseProvider);
JsonAggParam = Private(AggTypesParamTypesRawJsonProvider);
BaseParamType = Private(BaseParamTypeProvider);
JsonParamType = Private(JsonParamTypeProvider);

initAggParam();
initParamType();
}));

describe('constructor', function () {
it('it is an instance of BaseAggParam', function () {
expect(aggParam).to.be.a(BaseAggParam);
it('it is an instance of BaseParamType', function () {
expect(aggParam).to.be.a(BaseParamType);
});
});

Expand Down
18 changes: 9 additions & 9 deletions src/ui/public/agg_types/__tests__/param_types/_optioned.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base';
import { AggTypesParamTypesOptionedProvider } from 'ui/agg_types/param_types/optioned';
import { BaseParamTypeProvider } from '../../param_types/base';
import { OptionedParamTypeProvider } from '../../param_types/optioned';

describe('Optioned', function () {

let BaseAggParam;
let OptionedAggParam;
let BaseParamType;
let OptionedParamType;

beforeEach(ngMock.module('kibana'));
// fetch out deps
beforeEach(ngMock.inject(function (Private) {
BaseAggParam = Private(AggTypesParamTypesBaseProvider);
OptionedAggParam = Private(AggTypesParamTypesOptionedProvider);
BaseParamType = Private(BaseParamTypeProvider);
OptionedParamType = Private(OptionedParamTypeProvider);
}));

describe('constructor', function () {
it('it is an instance of BaseAggParam', function () {
const aggParam = new OptionedAggParam({
it('it is an instance of BaseParamType', function () {
const aggParam = new OptionedParamType({
name: 'some_param',
type: 'optioned'
});

expect(aggParam).to.be.a(BaseAggParam);
expect(aggParam).to.be.a(BaseParamType);
});
});
});
20 changes: 10 additions & 10 deletions src/ui/public/agg_types/__tests__/param_types/_regex.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base';
import { AggTypesParamTypesRegexProvider } from 'ui/agg_types/param_types/regex';
import { BaseParamTypeProvider } from '../../param_types/base';
import { RegexParamTypeProvider } from '../../param_types/regex';
import { VisProvider } from 'ui/vis';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

describe('Regex', function () {

let BaseAggParam;
let RegexAggParam;
let BaseParamType;
let RegexParamType;
let Vis;
let indexPattern;

beforeEach(ngMock.module('kibana'));
// fetch out deps
beforeEach(ngMock.inject(function (Private) {
BaseAggParam = Private(AggTypesParamTypesBaseProvider);
RegexAggParam = Private(AggTypesParamTypesRegexProvider);
BaseParamType = Private(BaseParamTypeProvider);
RegexParamType = Private(RegexParamTypeProvider);
Vis = Private(VisProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
}));

describe('constructor', function () {
it('should be an instance of BaseAggParam', function () {
const aggParam = new RegexAggParam({
it('should be an instance of BaseParamType', function () {
const aggParam = new RegexParamType({
name: 'some_param',
type: 'regex'
});

expect(aggParam).to.be.a(BaseAggParam);
expect(aggParam).to.be.a(BaseParamType);
expect(aggParam).to.have.property('write');
});
});
Expand All @@ -48,7 +48,7 @@ describe('Regex', function () {
});
aggConfig = vis.aggs[0];

aggParam = new RegexAggParam({
aggParam = new RegexParamType({
name: paramName,
type: 'regex'
});
Expand Down
18 changes: 9 additions & 9 deletions src/ui/public/agg_types/__tests__/param_types/_string.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base';
import { AggTypesParamTypesStringProvider } from 'ui/agg_types/param_types/string';
import { BaseParamTypeProvider } from '../../param_types/base';
import { StringParamTypeProvider } from '../../param_types/string';

// eslint-disable-next-line kibana-custom/no-default-export
export default describe('String', function () {
const paramName = 'json_test';
let BaseAggParam;
let StringAggParam;
let BaseParamType;
let StringParamType;
let aggParam;
let aggConfig;
let output;
Expand All @@ -20,24 +20,24 @@ export default describe('String', function () {
type: 'string'
};

aggParam = new StringAggParam(_.defaults(config, defaults));
aggParam = new StringParamType(_.defaults(config, defaults));
}

beforeEach(ngMock.module('kibana'));

// fetch our deps
beforeEach(ngMock.inject(function (Private) {
BaseAggParam = Private(AggTypesParamTypesBaseProvider);
StringAggParam = Private(AggTypesParamTypesStringProvider);
BaseParamType = Private(BaseParamTypeProvider);
StringParamType = Private(StringParamTypeProvider);

aggConfig = { params: {} };
output = { params: {} };
}));

describe('constructor', function () {
it('it is an instance of BaseAggParam', function () {
it('it is an instance of BaseParamType', function () {
initAggParam();
expect(aggParam).to.be.a(BaseAggParam);
expect(aggParam).to.be.a(BaseParamType);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/__tests__/param_types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import './_field';
import './_optioned';
import './_regex';
import './_string';
import './_raw_json';
import './_json';
describe('ParamTypes', function () {
});
12 changes: 6 additions & 6 deletions src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _ from 'lodash';
import sinon from 'sinon';
import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base';
import { AggTypesParamTypesFieldProvider } from 'ui/agg_types/param_types/field';
import { AggTypesParamTypesOptionedProvider } from 'ui/agg_types/param_types/optioned';
import { BaseParamTypeProvider } from '../../param_types/base';
import { FieldParamTypeProvider } from '../../param_types/field';
import { OptionedParamTypeProvider } from '../../param_types/optioned';

function ParamClassStub(parent, body) {
const stub = sinon.spy(body || function () {
Expand All @@ -29,19 +29,19 @@ function ParamClassStub(parent, body) {
// eslint-disable-next-line kibana-custom/no-default-export
export default function stubParamClasses(Private) {
const BaseAggParam = Private.stub(
AggTypesParamTypesBaseProvider,
BaseParamTypeProvider,
new ParamClassStub(null, function (config) {
_.assign(this, config);
})
);

Private.stub(
AggTypesParamTypesFieldProvider,
FieldParamTypeProvider,
new ParamClassStub(BaseAggParam)
);

Private.stub(
AggTypesParamTypesOptionedProvider,
OptionedParamTypeProvider,
new ParamClassStub(BaseAggParam)
);
}
Loading

0 comments on commit 199e5c3

Please sign in to comment.