Skip to content

Commit

Permalink
add tests for error edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Nov 4, 2020
1 parent a60d31c commit e0b51ef
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions src/plugins/data/common/search/aggs/utils/time_column_meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,43 @@ describe('getDateMetaByDatatableColumn', () => {
});
});

it('throws if unable to resolve interval', async () => {
await expect(
getDateMetaByDatatableColumn(params)({
id: 'test',
name: 'test',
meta: {
type: 'date',
source: 'esaggs',
sourceParams: {
type: BUCKET_TYPES.DATE_HISTOGRAM,
params: {
time_zone: 'UTC',
interval: 'auto',
},
},
},
})
).rejects.toBeDefined();

await expect(
getDateMetaByDatatableColumn(params)({
id: 'test',
name: 'test',
meta: {
type: 'date',
source: 'esaggs',
sourceParams: {
type: BUCKET_TYPES.DATE_HISTOGRAM,
params: {
time_zone: 'UTC',
},
},
},
})
).rejects.toBeDefined();
});

it('returns resolved auto interval', async () => {
expect(
await getDateMetaByDatatableColumn(params)({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const getDateMetaByDatatableColumn = ({
? calculateAutoTimeExpression(appliedTimeRange)
: params.interval;

if (!interval) {
if (!interval || interval === 'auto') {
throw new Error('time interval could not be determined');
}

Expand Down

0 comments on commit e0b51ef

Please sign in to comment.