Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[aggConfig] added test to prove 1ae3713
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Alger committed Nov 15, 2014
1 parent 1ae3713 commit cf3b6e3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/unit/specs/components/vis/_agg_configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,42 @@ define(function (require) {
expect(dsl[histo.id].aggs[metric.id]).to.not.have.property('aggs');
});
});

it('writes multiple metric aggregations at every level if the vis is hierarchical', function () {
var vis = new Vis(indexPattern, {
type: 'histogram',
aggs: [
{ type: 'terms', schema: 'segment', params: { field: 'ip' } },
{ type: 'terms', schema: 'segment', params: { field: 'extension' } },
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
{ type: 'sum', schema: 'metric', params: { field: 'bytes' } },
{ type: 'min', schema: 'metric', params: { field: 'bytes' } },
{ type: 'max', schema: 'metric', params: { field: 'bytes' } }
]
});
vis.isHierarchical = _.constant(true);

var topLevelDsl = vis.aggs.toDsl();
var buckets = vis.aggs.bySchemaGroup.buckets;
var metrics = vis.aggs.bySchemaGroup.metrics;

(function checkLevel(dsl) {
var bucket = buckets.shift();
expect(dsl).to.have.property(bucket.id);

expect(dsl[bucket.id]).to.be.an('object');
expect(dsl[bucket.id]).to.have.property('aggs');

metrics.forEach(function (metric) {
expect(dsl[bucket.id].aggs).to.have.property(metric.id);
expect(dsl[bucket.id].aggs[metric.id]).to.not.have.property('aggs');
});

if (buckets.length) {
checkLevel(dsl[bucket.id].aggs);
}
}(topLevelDsl));
});
});
}];
});

0 comments on commit cf3b6e3

Please sign in to comment.