annotations_srv.test.ts 969 B

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