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. describe('AnnotationsSrv', function() {
  5. var ctx = new helpers.ServiceTestContext();
  6. beforeEach(angularMocks.module('grafana.core'));
  7. beforeEach(angularMocks.module('grafana.services'));
  8. beforeEach(() => {
  9. ctx.createService('annotationsSrv');
  10. });
  11. describe('When translating the query result', () => {
  12. const annotationSource = {
  13. datasource: '-- Grafana --',
  14. enable: true,
  15. hide: false,
  16. limit: 200,
  17. name: 'test',
  18. scope: 'global',
  19. tags: [
  20. 'test'
  21. ],
  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. });