The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/annotations/events_processing.test.ts

39 lines
1.0 KiB

import { dedupAnnotations } from './events_processing';
describe('Annotations deduplication', () => {
it('should remove duplicated annotations', () => {
const testAnnotations = [
{ id: 1, time: 1 },
{ id: 2, time: 2 },
{ id: 2, time: 2 },
{ id: 5, time: 5 },
{ id: 5, time: 5 },
];
const expectedAnnotations = [
{ id: 1, time: 1 },
{ id: 2, time: 2 },
{ id: 5, time: 5 },
];
const deduplicated = dedupAnnotations(testAnnotations);
expect(deduplicated).toEqual(expectedAnnotations);
});
it('should leave non "panel-alert" event if present', () => {
const testAnnotations = [
{ id: 1, time: 1 },
{ id: 2, time: 2 },
{ id: 2, time: 2, eventType: 'panel-alert' },
{ id: 5, time: 5 },
{ id: 5, time: 5 },
];
const expectedAnnotations = [
{ id: 1, time: 1 },
{ id: 2, time: 2 },
{ id: 5, time: 5 },
];
const deduplicated = dedupAnnotations(testAnnotations);
expect(deduplicated).toEqual(expectedAnnotations);
});
});