当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript common.it函数代码示例

本文整理汇总了TypeScript中test/lib/common.it函数的典型用法代码示例。如果您正苦于以下问题:TypeScript it函数的具体用法?TypeScript it怎么用?TypeScript it使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了it函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

 describe('When performing performSuggestQuery', function() {
   var results;
   var response;
   it('cache response', function() {
     response = {
       status: "success",
       data: ["value1", "value2", "value3"]
     };
     ctx.$httpBackend.expect('GET', 'proxied/api/v1/label/__name__/values').respond(response);
     ctx.ds.performSuggestQuery('value', true).then(function(data) { results = data; });
     ctx.$httpBackend.flush();
     ctx.$rootScope.$apply();
     expect(results.length).to.be(3);
     ctx.ds.performSuggestQuery('value', true).then(function (data) {
       // get from cache, no need to flush
       results = data;
       expect(results.length).to.be(3);
     });
   });
 });
开发者ID:PaulMest,项目名称:grafana,代码行数:20,代码来源:metric_find_query_specs.ts

示例2: describe

  describe('when loading metric sources', function() {
    var unsortedDatasources = {
      'mmm': {
        type: 'test-db',
        meta: { metrics: {m: 1} }
      },
      '--Grafana--': {
        type: 'grafana',
        meta: {builtIn: true, metrics: {m: 1}, id: "grafana"}
      },
      '--Mixed--': {
        type: 'test-db',
        meta: {builtIn: true, metrics: {m: 1}, id: "mixed"}
      },
      'ZZZ': {
        type: 'test-db',
        meta: {metrics: {m: 1} }
      },
      'aaa': {
        type: 'test-db',
        meta: { metrics: {m: 1} }
      },
      'BBB': {
        type: 'test-db',
        meta: { metrics: {m: 1} }
      },
    };
    beforeEach(function() {
      config.datasources = unsortedDatasources;
      metricSources = _datasourceSrv.getMetricSources({skipVariables: true});
    });

    it('should return a list of sources sorted case insensitively with builtin sources last', function() {
      expect(metricSources[0].name).to.be('aaa');
      expect(metricSources[1].name).to.be('BBB');
      expect(metricSources[2].name).to.be('mmm');
      expect(metricSources[3].name).to.be('ZZZ');
      expect(metricSources[4].name).to.be('--Grafana--');
      expect(metricSources[5].name).to.be('--Mixed--');
    });
  });
开发者ID:PaulMest,项目名称:grafana,代码行数:41,代码来源:datasource_srv_specs.ts

示例3: describe

  describe('simple query and count', function() {
    beforeEach(function() {
      targets = [
        {
          refId: 'A',
          metrics: [{ type: 'count', id: '1' }],
          bucketAggs: [{ type: 'date_histogram', field: '@timestamp', id: '2' }],
        },
      ];
      response = {
        responses: [
          {
            aggregations: {
              '2': {
                buckets: [
                  {
                    doc_count: 10,
                    key: 1000,
                  },
                  {
                    doc_count: 15,
                    key: 2000,
                  },
                ],
              },
            },
          },
        ],
      };

      result = new ElasticResponse(targets, response).getTimeSeries();
    });

    it('should return 1 series', function() {
      expect(result.data.length).to.be(1);
      expect(result.data[0].target).to.be('Count');
      expect(result.data[0].datapoints.length).to.be(2);
      expect(result.data[0].datapoints[0][0]).to.be(10);
      expect(result.data[0].datapoints[0][1]).to.be(1000);
    });
  });
开发者ID:GPegel,项目名称:grafana,代码行数:41,代码来源:elastic_response_specs.ts

示例4: describe

  describe('given 2 subscribers', () => {

    it('should notfiy subscribers', () => {
      var events = new Emitter();
      var sub1Called = false;
      var sub2Called = false;

      events.on('test', () => {
        sub1Called = true;
      });
      events.on('test', () => {
        sub2Called = true;
      });

      events.emit('test', null);

      expect(sub1Called).to.be(true);
      expect(sub2Called).to.be(true);
    });

    it.only('should handle errors', () => {
      var events = new Emitter();
      var sub1Called = 0;
      var sub2Called = 0;

      events.on('test', () => {
        sub1Called++;
        throw "hello";
      });

      events.on('test', () => {
        sub2Called++;
      });

      try { events.emit('test', null); } catch (_) { }
      try { events.emit('test', null); } catch (_) {}

      expect(sub1Called).to.be(2);
      expect(sub2Called).to.be(0);
    });
  });
开发者ID:cmac458,项目名称:grafana,代码行数:41,代码来源:emitter_specs.ts

示例5: describe

 describe('When performing annotationQuery', function () {
   var results;
   var urlExpected = 'proxied/api/v1/query_range?query=' +
                     encodeURIComponent('ALERTS{alertstate="firing"}') +
                     '&start=1443438675&end=1443460275&step=60s';
   var options = {
     annotation: {
       expr: 'ALERTS{alertstate="firing"}',
       tagKeys: 'job',
       titleFormat: '{{alertname}}',
       textFormat: '{{instance}}'
     },
     range: {
       from: moment(1443438674760),
       to: moment(1443460274760)
     }
   };
   var response = {
     status: "success",
     data: {
       resultType: "matrix",
       result: [{
         metric: {"__name__": "ALERTS", alertname: "InstanceDown", alertstate: "firing", instance: "testinstance", job: "testjob"},
         values: [[1443454528, "1"]]
       }]
     }
   };
   beforeEach(function() {
     ctx.$httpBackend.expect('GET', urlExpected).respond(response);
     ctx.ds.annotationQuery(options).then(function(data) { results = data; });
     ctx.$httpBackend.flush();
   });
   it('should return annotation list', function() {
     ctx.$rootScope.$apply();
     expect(results.length).to.be(1);
     expect(results[0].tags).to.contain('testjob');
     expect(results[0].title).to.be('InstanceDown');
     expect(results[0].text).to.be('testinstance');
     expect(results[0].time).to.be(1443454528 * 1000);
   });
 });
开发者ID:PaulMest,项目名称:grafana,代码行数:41,代码来源:datasource_specs.ts

示例6: describe

  describe('given measurement with dots', function() {
    var options = {
      alias: '',
      series: [
        {
          name: 'app.prod.server1.count',
          tags:  {},
          columns: ['time', 'mean'],
          values: [[1431946625000, 10], [1431946626000, 12]]
        }
      ]
    };

    it('should replace patterns', function() {
      options.alias = 'alias: $1 -> [[3]]';
      var series = new InfluxSeries(options);
      var result = series.getTimeSeries();

      expect(result[0].target).to.be('alias: prod -> count');
    });
  });
开发者ID:eddawley,项目名称:grafana,代码行数:21,代码来源:influx_series_specs.ts

示例7: describe

  describe('When querying influxdb with one raw query', function() {
    var results;
    var urlExpected = "/series?p=mupp&q=select+value+from+series+where+time+%3E+now()-1h";
    var query = {
      rangeRaw: { from: 'now-1h', to: 'now' },
      targets: [{ query: "select value from series where $timeFilter", rawQuery: true }]
    };

    var response = [];

    beforeEach(function() {
      ctx.$httpBackend.expect('GET', urlExpected).respond(response);
      ctx.ds.query(query).then(function(data) { results = data; });
      ctx.$httpBackend.flush();
    });

    it('should generate the correct query', function() {
      ctx.$httpBackend.verifyNoOutstandingExpectation();
    });

  });
开发者ID:3r1ccc,项目名称:grafana,代码行数:21,代码来源:datasource-specs.ts

示例8: describe

    describe("response from 0.11.0", () => {
      var response = {
        "results": [
          {
            "series": [
              {
                "name": "cpu",
                "columns": ["fieldKey"],
                "values": [ [ "value"] ]
              }
            ]
          }
        ]
      };

      var result = this.parser.parse(query, response);

      it("should get two responses", () => {
        expect(_.size(result)).to.be(1);
      });
    });
开发者ID:PaulMest,项目名称:grafana,代码行数:21,代码来源:response_parser_specs.ts

示例9: describe

  describe('When performing metricFindQuery with key, value columns', function() {
    let results;
    const query = 'select * from atable';
    const response = {
      results: {
        tempvar: {
          meta: {
            rowCount: 3
          },
          refId: 'tempvar',
          tables: [
            {
              columns: [{text: '__value'}, {text: '__text'}],
              rows: [
                ['value1', 'aTitle'],
                ['value2', 'aTitle2'],
                ['value3', 'aTitle3']
              ]
            }
          ]
        }
      }
    };

    beforeEach(function() {
      ctx.backendSrv.datasourceRequest = function(options) {
        return ctx.$q.when({data: response, status: 200});
      };
      ctx.ds.metricFindQuery(query).then(function(data) { results = data; });
      ctx.$rootScope.$apply();
    });

    it('should return list of as text, value', function() {
      expect(results.length).to.be(3);
      expect(results[0].text).to.be('aTitle');
      expect(results[0].value).to.be('value1');
      expect(results[2].text).to.be('aTitle3');
      expect(results[2].value).to.be('value3');
    });
  });
开发者ID:connection-reset,项目名称:grafana,代码行数:40,代码来源:datasource_specs.ts


注:本文中的test/lib/common.it函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。