• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript common.it类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: describe

  describe('After a second iteration', function() {
    var repeatedRowAfterFirstIteration;

    beforeEach(function() {
      repeatedRowAfterFirstIteration = ctx.rows[1];
      ctx.rows[0].height = 500;
      ctx.dynamicDashboardSrv.update(ctx.dash);
    });

    it('should still only have 2 rows', function() {
      expect(ctx.rows.length).to.be(3);
    });

    it.skip('should have updated props from source', function() {
      expect(ctx.rows[1].height).to.be(500);
    });

    it('should reuse row instance', function() {
      expect(ctx.rows[1]).to.be(repeatedRowAfterFirstIteration);
    });
  });
开发者ID:joelanford,项目名称:grafana,代码行数:21,代码来源:dynamic_dashboard_srv_specs.ts


示例3: describe

describe('unsavedChangesSrv', function() {
  var _dashboardSrv;
  var _contextSrvStub = { isEditor: true };
  var _rootScope;
  var _location;
  var _timeout;
  var _window;
  var tracker;
  var dash;
  var scope;

  beforeEach(angularMocks.module('grafana.core'));
  beforeEach(angularMocks.module('grafana.services'));
  beforeEach(
    angularMocks.module(function($provide) {
      $provide.value('contextSrv', _contextSrvStub);
      $provide.value('$window', {});
    })
  );

  beforeEach(
    angularMocks.inject(function($location, $rootScope, dashboardSrv, $timeout, $window) {
      _dashboardSrv = dashboardSrv;
      _rootScope = $rootScope;
      _location = $location;
      _timeout = $timeout;
      _window = $window;
    })
  );

  beforeEach(function() {
    dash = _dashboardSrv.create({
      refresh: false,
      panels: [{ test: 'asd', legend: {} }],
      rows: [
        {
          panels: [{ test: 'asd', legend: {} }],
        },
      ],
    });
    scope = _rootScope.$new();
    scope.appEvent = sinon.spy();
    scope.onAppEvent = sinon.spy();

    tracker = new Tracker(dash, scope, undefined, _location, _window, _timeout, contextSrv, _rootScope);
  });

  it('No changes should not have changes', function() {
    expect(tracker.hasChanges()).to.be(false);
  });

  it('Simple change should be registered', function() {
    dash.property = 'google';
    expect(tracker.hasChanges()).to.be(true);
  });

  it('Should ignore a lot of changes', function() {
    dash.time = { from: '1h' };
    dash.refresh = true;
    dash.schemaVersion = 10;
    expect(tracker.hasChanges()).to.be(false);
  });

  it.skip('Should ignore row collapse change', function() {
    dash.rows[0].collapse = true;
    expect(tracker.hasChanges()).to.be(false);
  });

  it('Should ignore panel legend changes', function() {
    dash.panels[0].legend.sortDesc = true;
    dash.panels[0].legend.sort = 'avg';
    expect(tracker.hasChanges()).to.be(false);
  });

  it.skip('Should ignore panel repeats', function() {
    dash.rows[0].panels.push({ repeatPanelId: 10 });
    expect(tracker.hasChanges()).to.be(false);
  });

  it.skip('Should ignore row repeats', function() {
    dash.addEmptyRow();
    dash.rows[1].repeatRowId = 10;
    expect(tracker.hasChanges()).to.be(false);
  });
});
开发者ID:GPegel,项目名称:grafana,代码行数:85,代码来源:unsaved_changes_srv_specs.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript common.sinon类代码示例发布时间:2022-05-25
下一篇:
TypeScript common.angularMocks类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap