Skip to content

Commit

Permalink
Add test for aggregating ConditionField
Browse files Browse the repository at this point in the history
  • Loading branch information
kanitw committed Jun 9, 2017
1 parent 902dbb9 commit 584361b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/compile/data/aggregate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import {assert} from 'chai';

import {AggregateNode} from '../../../src/compile/data/aggregate';
import {Condition} from '../../../src/fielddef';
import {SummarizeTransform} from '../../../src/transform';
import {StringSet} from '../../../src/util';
import {VgAggregateTransform} from '../../../src/vega.schema';
Expand Down Expand Up @@ -79,6 +80,28 @@ describe('compile/data/summary', function () {
});
});

it('should include conditional field in the summary component', function() {
const model = parseUnitModel({
mark: "point",
encoding: {
'x': {'aggregate': 'mean', 'field': 'Displacement', 'type': "quantitative"},
color: {
condition: {selection: 'a', field: 'Origin', 'type': "ordinal"},
value: 'red'
}
}
});

const agg = AggregateNode.makeFromEncoding(model);
assert.deepEqual<VgAggregateTransform>(agg.assemble(), {
type: 'aggregate',
groupby: ['Origin'],
ops: ['mean'],
fields: ['Displacement'],
as: ['mean_Displacement']
});
});

it('should add min and max if needed for unaggregated scale domain', function() {
const model = parseUnitModel({
mark: "point",
Expand Down

0 comments on commit 584361b

Please sign in to comment.