annotations_srv.test.ts 1.0 KB

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