events_processing.test.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 = [
  12. { id: 1, time: 1 },
  13. { id: 2, time: 2 },
  14. { id: 5, time: 5 },
  15. ];
  16. const deduplicated = dedupAnnotations(testAnnotations);
  17. expect(deduplicated).toEqual(expectedAnnotations);
  18. });
  19. it('should leave non "panel-alert" event if present', () => {
  20. const testAnnotations = [
  21. { id: 1, time: 1 },
  22. { id: 2, time: 2 },
  23. { id: 2, time: 2, eventType: 'panel-alert' },
  24. { id: 5, time: 5 },
  25. { id: 5, time: 5 },
  26. ];
  27. const expectedAnnotations = [
  28. { id: 1, time: 1 },
  29. { id: 2, time: 2 },
  30. { id: 5, time: 5 },
  31. ];
  32. const deduplicated = dedupAnnotations(testAnnotations);
  33. expect(deduplicated).toEqual(expectedAnnotations);
  34. });
  35. });