Files
grafana/public/app/features/annotations/specs/annotations_srv_specs.test.ts
Ryan McKinley 6335509a23 Annotations: use a single row to represent a region (#17673)
* SQLite migrations

* cleanup

* migrate end times

* switch to update with a query

* real migration

* anno migrations

* remove old docs

* set isRegion from time changes

* use <> for is not

* add comment and fix index decleration

* single validation place

* add test

* fix test

* add upgrading docs

* use AnnotationEvent

* fix import

* remove regionId from typescript
2019-08-16 10:49:30 +02:00

32 lines
1018 B
TypeScript

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);
});
});