annotations_srv_specs.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { describe, beforeEach, it, expect, angularMocks } from 'test/lib/common';
  2. import '../annotations_srv';
  3. import helpers from 'test/specs/helpers';
  4. import 'app/features/dashboard/time_srv';
  5. describe('AnnotationsSrv', function() {
  6. var ctx = new helpers.ServiceTestContext();
  7. beforeEach(angularMocks.module('grafana.core'));
  8. beforeEach(angularMocks.module('grafana.services'));
  9. beforeEach(ctx.createService('timeSrv'));
  10. beforeEach(() => {
  11. ctx.createService('annotationsSrv');
  12. });
  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 = ctx.service.translateQueryResult(annotationSource, annotations);
  29. });
  30. it('should set defaults', () => {
  31. expect(translatedAnnotations[0].source).to.eql(annotationSource);
  32. });
  33. });
  34. });