2019-08-16 01:49:30 -07:00
|
|
|
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 },
|
|
|
|
|
];
|
2019-11-19 13:59:39 +00:00
|
|
|
const expectedAnnotations = [
|
|
|
|
|
{ id: 1, time: 1 },
|
|
|
|
|
{ id: 2, time: 2 },
|
|
|
|
|
{ id: 5, time: 5 },
|
|
|
|
|
];
|
2019-08-16 01:49:30 -07:00
|
|
|
|
|
|
|
|
const deduplicated = dedupAnnotations(testAnnotations);
|
|
|
|
|
expect(deduplicated).toEqual(expectedAnnotations);
|
2017-10-23 16:46:36 +03:00
|
|
|
});
|
|
|
|
|
|
2019-08-16 01:49:30 -07:00
|
|
|
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 },
|
|
|
|
|
];
|
2019-11-19 13:59:39 +00:00
|
|
|
const expectedAnnotations = [
|
|
|
|
|
{ id: 1, time: 1 },
|
|
|
|
|
{ id: 2, time: 2 },
|
|
|
|
|
{ id: 5, time: 5 },
|
|
|
|
|
];
|
2019-08-16 01:49:30 -07:00
|
|
|
|
|
|
|
|
const deduplicated = dedupAnnotations(testAnnotations);
|
|
|
|
|
expect(deduplicated).toEqual(expectedAnnotations);
|
2017-10-23 16:46:36 +03:00
|
|
|
});
|
|
|
|
|
});
|