annotations_srv.test.ts 898 B

12345678910111213141516171819202122232425262728293031323334
  1. import { AnnotationsSrv } from '../annotations_srv';
  2. describe('AnnotationsSrv', () => {
  3. const $rootScope = {
  4. onAppEvent: jest.fn(),
  5. };
  6. const annotationsSrv = new AnnotationsSrv($rootScope, null, null, null, null);
  7. describe('When translating the query result', () => {
  8. const annotationSource = {
  9. datasource: '-- Grafana --',
  10. enable: true,
  11. hide: false,
  12. limit: 200,
  13. name: 'test',
  14. scope: 'global',
  15. tags: ['test'],
  16. type: 'event',
  17. };
  18. const time = 1507039543000;
  19. const annotations = [{ id: 1, panelId: 1, text: 'text', time: time }];
  20. let translatedAnnotations;
  21. beforeEach(() => {
  22. translatedAnnotations = annotationsSrv.translateQueryResult(annotationSource, annotations);
  23. });
  24. it('should set defaults', () => {
  25. expect(translatedAnnotations[0].source).toEqual(annotationSource);
  26. });
  27. });
  28. });