Add tests to cover PlaceholdersBuffer and sum hint

Related: #13615
This commit is contained in:
Michael Huynh
2018-10-28 21:07:40 +08:00
parent c255b5da11
commit d1d5e9f7d3
2 changed files with 92 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
import { getQueryHints } from '../query_hints';
import { getQueryHints, SUM_HINT_THRESHOLD_COUNT } from '../query_hints';
describe('getQueryHints()', () => {
it('returns no hints for no series', () => {
@@ -79,4 +79,23 @@ describe('getQueryHints()', () => {
},
});
});
it('returns a sum hint when many time series results are returned for a simple metric', () => {
const seriesCount = SUM_HINT_THRESHOLD_COUNT;
const series = Array.from({ length: seriesCount }, _ => ({
datapoints: [[0, 0], [0, 0]],
}));
const hints = getQueryHints('metric', series);
expect(hints.length).toBe(seriesCount);
expect(hints[0]).toMatchObject({
label: 'Many time series results returned.',
index: 0,
fix: {
action: {
type: 'ADD_SUM',
query: 'metric',
},
},
});
});
});