annotations_srv_specs.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {
  2. describe,
  3. beforeEach,
  4. it,
  5. expect,
  6. angularMocks
  7. } from "test/lib/common";
  8. import "../annotations_srv";
  9. import helpers from "test/specs/helpers";
  10. describe("AnnotationsSrv", function() {
  11. var ctx = new helpers.ServiceTestContext();
  12. beforeEach(angularMocks.module("grafana.core"));
  13. beforeEach(angularMocks.module("grafana.services"));
  14. beforeEach(() => {
  15. ctx.createService("annotationsSrv");
  16. });
  17. describe("When translating the query result", () => {
  18. const annotationSource = {
  19. datasource: "-- Grafana --",
  20. enable: true,
  21. hide: false,
  22. limit: 200,
  23. name: "test",
  24. scope: "global",
  25. tags: ["test"],
  26. type: "event"
  27. };
  28. const time = 1507039543000;
  29. const annotations = [{ id: 1, panelId: 1, text: "text", time: time }];
  30. let translatedAnnotations;
  31. beforeEach(() => {
  32. translatedAnnotations = ctx.service.translateQueryResult(
  33. annotationSource,
  34. annotations
  35. );
  36. });
  37. it("should set defaults", () => {
  38. expect(translatedAnnotations[0].source).to.eql(annotationSource);
  39. });
  40. });
  41. });