Files
superset2/superset/assets/spec/javascripts/superset-ui/buildQueryObject.test.ts
Christine Chambers c11e9c8b67 [SIP-5] Build metrics in query_object in the client
- Unify the metric interface (absorb the current plain string metric for built-in metric keys into the format used by adhoc metric)
- Port the logic in adhocMetric on the client and process_metrics in the backend to the new typed Metrics class
- Omit hasCustomLabel and formFromData properties from the new metric interface as their value can be inferred from label and optionName
- Expose from the Metrics class both metrics and their labels as public methods to match the all_metrics and metric_labels fields in the backend code
- Provide defaut values for filters, metrics and groupby in the backend
2018-11-28 19:39:18 -05:00

25 lines
726 B
TypeScript

import build, { QueryObject } from 'src/query/buildQueryObject';
describe('queryObjectBuilder', () => {
let query: QueryObject;
it('should build granularity for sql alchemy datasources', () => {
query = build({datasource: '5__table', granularity_sqla: 'ds'});
expect(query.granularity).toEqual('ds');
});
it('should build granularity for sql alchemy datasources', () => {
query = build({datasource: '5__druid', granularity: 'ds'});
expect(query.granularity).toEqual('ds');
});
it('should build metrics', () => {
query = build({
datasource: '5__table',
granularity_sqla: 'ds',
metric: 'sum__num',
});
expect(query.metrics).toEqual([{label: 'sum__num'}]);
});
});