Browse Source

prometheus: added completer unit test, #9208

Torkel Ödegaard 8 years ago
parent
commit
3c16230158
1 changed files with 27 additions and 0 deletions
  1. 27 0
      public/app/plugins/datasource/prometheus/specs/completer_specs.ts

+ 27 - 0
public/app/plugins/datasource/prometheus/specs/completer_specs.ts

@@ -0,0 +1,27 @@
+import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
+
+import {PromCompleter} from '../completer';
+import {PrometheusDatasource} from '../datasource';
+
+describe('Prometheus editor completer', function() {
+
+  let editor = {};
+  let session = {
+    getTokenAt: sinon.stub().returns({}),
+    getLine:  sinon.stub().returns(""),
+  };
+
+  let datasourceStub = <PrometheusDatasource>{};
+  let completer = new PromCompleter(datasourceStub);
+
+  describe("When inside brackets", () => {
+
+    it("Should return range vectors", () => {
+      completer.getCompletions(editor, session, 10, "[", (s, res) => {
+        expect(res[0]).to.eql({caption: '1s', value: '[1s', meta: 'range vector'});
+      });
+    });
+
+  });
+
+});