mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
add some tests for the regex param type
This commit is contained in:
parent
1dd879cde4
commit
cfd20ab3c4
1 changed files with 44 additions and 1 deletions
|
@ -13,7 +13,7 @@ define(function (require) {
|
|||
}));
|
||||
|
||||
describe('constructor', function () {
|
||||
it('it is an instance of BaseAggParam', function () {
|
||||
it('should be an instance of BaseAggParam', function () {
|
||||
var aggParam = new RegexAggParam({
|
||||
name: 'some_param',
|
||||
type: 'regex'
|
||||
|
@ -21,6 +21,49 @@ define(function (require) {
|
|||
|
||||
expect(aggParam).to.be.a(BaseAggParam);
|
||||
});
|
||||
|
||||
it('should not include param in output', function () {
|
||||
var paramName = 'exclude';
|
||||
var aggParam = new RegexAggParam({
|
||||
name: paramName,
|
||||
type: 'regex'
|
||||
});
|
||||
|
||||
var aggConfig = { params: {} };
|
||||
var output = { params: {} };
|
||||
aggConfig.params[paramName] = {
|
||||
pattern: ''
|
||||
};
|
||||
|
||||
expect(aggParam).to.have.property('write');
|
||||
|
||||
aggParam.write(aggConfig, output);
|
||||
expect(output).to.be.an('object');
|
||||
expect(output).to.have.property('params');
|
||||
expect(output.params).not.to.have.property(paramName);
|
||||
});
|
||||
|
||||
it('should include param in output', function () {
|
||||
var paramName = 'exclude';
|
||||
var aggParam = new RegexAggParam({
|
||||
name: paramName,
|
||||
type: 'regex'
|
||||
});
|
||||
|
||||
var aggConfig = { params: {} };
|
||||
var output = { params: {} };
|
||||
aggConfig.params[paramName] = {
|
||||
pattern: 'testing'
|
||||
};
|
||||
|
||||
expect(aggParam).to.have.property('write');
|
||||
|
||||
aggParam.write(aggConfig, output);
|
||||
expect(output).to.be.an('object');
|
||||
expect(output).to.have.property('params');
|
||||
expect(output.params).to.have.property(paramName);
|
||||
expect(output.params[paramName]).to.eql({ pattern: 'testing' });
|
||||
});
|
||||
});
|
||||
}];
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue