annotations_srv_specs.test.ts 1018 B

12345678910111213141516171819202122232425262728293031
  1. import { dedupAnnotations } from '../events_processing';
  2. describe('Annotations deduplication', () => {
  3. it('should remove duplicated annotations', () => {
  4. const testAnnotations = [
  5. { id: 1, time: 1 },
  6. { id: 2, time: 2 },
  7. { id: 2, time: 2 },
  8. { id: 5, time: 5 },
  9. { id: 5, time: 5 },
  10. ];
  11. const expectedAnnotations = [{ id: 1, time: 1 }, { id: 2, time: 2 }, { id: 5, time: 5 }];
  12. const deduplicated = dedupAnnotations(testAnnotations);
  13. expect(deduplicated).toEqual(expectedAnnotations);
  14. });
  15. it('should leave non "panel-alert" event if present', () => {
  16. const testAnnotations = [
  17. { id: 1, time: 1 },
  18. { id: 2, time: 2 },
  19. { id: 2, time: 2, eventType: 'panel-alert' },
  20. { id: 5, time: 5 },
  21. { id: 5, time: 5 },
  22. ];
  23. const expectedAnnotations = [{ id: 1, time: 1 }, { id: 2, time: 2 }, { id: 5, time: 5 }];
  24. const deduplicated = dedupAnnotations(testAnnotations);
  25. expect(deduplicated).toEqual(expectedAnnotations);
  26. });
  27. });