Files
grafana/public/app/plugins/datasource/elasticsearch/guards.test.ts
Matias Chomicki a75752b085 Elasticsearch: remove usages of any (#69575)
* Elasticsearch: remove usages of any

* Elasticsearch: check for filter type when accessing field aggs

* Elasticsearch: use type guards instead of checking types

* Use unknown for isPrimitive function

* Add deprecation notice

* Remove unused type

* Fix bug in "isPrimitive" function

* Remove unused import

* Revert "Fix bug in "isPrimitive" function"

This reverts commit 27f9874cce.
2023-06-19 11:01:08 +02:00

24 lines
610 B
TypeScript

import { Count, ExtendedStats } from './dataquery.gen';
import { isMetricAggregationWithMeta } from './guards';
describe('Type guards', () => {
test('Identifies metrics with meta attribute', () => {
const metric: ExtendedStats = {
id: 'test',
type: 'extended_stats',
meta: {
test: 'test',
},
};
expect(isMetricAggregationWithMeta(metric)).toBe(true);
});
test('Identifies metrics without meta attribute', () => {
const metric: Count = {
id: 'test',
type: 'count',
};
expect(isMetricAggregationWithMeta(metric)).toBe(false);
});
});