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

TypeScript testing.TestContext类代码示例

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

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



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

示例1: xdescribe

  xdescribe('UserEditPage', () => {

    var ctx:TestContext;

    var cmpDebugElement:DebugElement;

    var routeParams:RouteParams;

    beforeEachProviders(() => {
      routeParams = jasmine.createSpyObj('routeParams', ['get']);

      return [
        APP_TEST_PROVIDERS,
        provide(RouteParams, {useValue: routeParams}),
      ]
    });
    beforeEach(createTestContext(_  => ctx = _));

    beforeEach(done => {
      ctx.init(TestCmp)
        .finally(done)
        .subscribe(() => {
          cmpDebugElement = ctx.fixture.debugElement.query(By.directive(UserEditPage));
        }, console.error);
    });

    it('can be shown', () => {
      expect(cmpDebugElement).toBeTruthy();
    });

  });
开发者ID:windwang,项目名称:angular2-app,代码行数:31,代码来源:UserEditPage.spec.ts


示例2: describe

  describe('SecurityRouterOutlet', () => {

    var ctx:TestContext;

    beforeEachProviders(() => [
      APP_TEST_PROVIDERS,
      provide(ROUTER_PRIMARY_COMPONENT, {useValue: TestCmp}),
    ]);
    beforeEach(createTestContext(_ => ctx = _));

    describe('when not signed in', () => {
      beforeEach(done => {
        ctx.init(TestCmp)
          .finally(done)
          .subscribe();
      });

      it('allows the access to public page', (done) => {
        ctx.router.navigate(['/PublicCmp']).then(() => {
          expect(ctx.location.path()).toEqual('/public');
          done();
        });
      });

      it('force redirect to login page when accessed to private page', (done) => {
        ctx.router.navigate(['/PrivateCmp']).then(() => {
          ctx.router.subscribe(() => {
            expect(ctx.location.path()).toEqual('/login');
            done();
          });
        });
      });
    }); // when not signed in

    describe('when signed in', () => {
      beforeEach(signin());
      beforeEach(done => {
        ctx.init(TestCmp)
          .finally(done)
          .subscribe();
      });

      it('allows the access to private page', (done) => {
        ctx.router.navigate(['/PrivateCmp']).then(() => {
          expect(ctx.location.path()).toEqual('/private');
          done();
        });
      });

      it('force redirect to specified page when accessed to a page like login page', (done) => {
        ctx.router.navigate(['/Login']).then(() => {
          ctx.router.subscribe(() => {
            expect(ctx.location.path()).toEqual('/public');
            done();
          });
        });
      });
    }); // when signed in

  });
开发者ID:windwang,项目名称:angular2-app,代码行数:60,代码来源:SecurityRouterOutlet.spec.ts


示例3: describe

describe('Gravatar', () => {

  var ctx:TestContext;
  var cmpDebugElement:DebugElement;

  beforeEachProviders(() => [
    APP_TEST_PROVIDERS,
    provide(ROUTER_PRIMARY_COMPONENT, {useValue: App}),
  ]);
  beforeEach(createTestContext(_ => ctx = _));
  beforeEach(done => {
    ctx.init(TestCmp)
      .finally(done)
      .subscribe(() => {
        cmpDebugElement = ctx.fixture.debugElement.query(By.directive(Gravatar));
      });
  });

  it('can be shown', () => {
    expect(cmpDebugElement).toBeTruthy();

    const cmp:Gravatar = cmpDebugElement.componentInstance;
    expect(cmp.email).toEqual('[email protected]');
    expect(cmp.alt).toEqual('test-alt');
    expect(cmp.size).toEqual('1');

    const el = cmpDebugElement.nativeElement;
    expect(DOM.querySelector(el, 'img').getAttribute('src'))
      .toEqual('https://secure.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=1');
  });

});
开发者ID:gtostock,项目名称:angular2-app,代码行数:32,代码来源:Gravatar.spec.ts


示例4: describe

describe('HomePage', () => {

  var ctx:TestContext;

  var cmpDebugElement:DebugElement;
  var userStatsDebugElement:DebugElement;
  var micropostNewDebugElement:DebugElement;
  var feedDebugElement:DebugElement;

  beforeEachProviders(() => [
    APP_TEST_PROVIDERS,
    provide(ROUTER_PRIMARY_COMPONENT, {useValue: App}),
  ]);
  beforeEach(createTestContext(_ => ctx = _));

  function createCmp(done) {
    ctx.init(TestCmp)
      .finally(done)
      .subscribe(() => {
        cmpDebugElement = ctx.fixture.debugElement.query(By.directive(HomePage));
        if (!cmpDebugElement) return;
        userStatsDebugElement = cmpDebugElement.query(By.directive(UserStats));
        micropostNewDebugElement = cmpDebugElement.query(By.directive(MicropostNew));
        feedDebugElement = cmpDebugElement.query(By.directive(Feed));
      });
  }

  beforeEach(createCmp);

  it('can be shown', () => {
    expect(cmpDebugElement).toBeTruthy();
    expect(userStatsDebugElement).toBeTruthy();
    expect(userStatsDebugElement.componentInstance.userId).toEqual('me');
    expect(micropostNewDebugElement).toBeTruthy();
    expect(feedDebugElement).toBeTruthy();
  });

  it('reload user stats when created new micropost', () => {
    const userStats:UserStats = userStatsDebugElement.componentInstance;
    spyOn(userStats, 'ngOnChanges');
    micropostNewDebugElement.triggerEventHandler('created', null);
    expect(userStats.ngOnChanges).toHaveBeenCalled();
  });

  it('reload feed when created new micropost', () => {
    const feed:Feed = feedDebugElement.componentInstance;
    spyOn(feed, 'list');
    micropostNewDebugElement.triggerEventHandler('created', null);
    expect(feed.list).toHaveBeenCalled();
  });

  it('reload user stats when deleted a micropost', () => {
    const userStats:UserStats = userStatsDebugElement.componentInstance;
    spyOn(userStats, 'ngOnChanges');
    feedDebugElement.triggerEventHandler('deleted', null);
    expect(userStats.ngOnChanges).toHaveBeenCalled();
  });

});
开发者ID:mauricio1990silva,项目名称:angular2-app,代码行数:59,代码来源:HomePage.spec.ts


示例5: createCmp

 function createCmp(done) {
   ctx.init(TestCmp)
     .finally(done)
     .subscribe(() => {
       cmpDebugElement = ctx.fixture.debugElement.query(By.directive(UserList));
     });
 }
开发者ID:gtostock,项目名称:angular2-app,代码行数:7,代码来源:UserList.spec.ts


示例6: beforeEach

 beforeEach((done) => {
   ctx.init(TestCmp)
     .finally(done)
     .subscribe(() => {
       cmpDebugElement = ctx.fixture.debugElement.query(By.directive(HelpPage));
     });
 });
开发者ID:mauricio1990silva,项目名称:angular2-app,代码行数:7,代码来源:HelpPage.spec.ts


示例7: beforeEach

 beforeEach(done => {
   ctx.init(TestCmp)
     .finally(done)
     .subscribe(() => {
       cmpDebugElement = ctx.fixture.debugElement.query(By.directive(UserEditPage));
     }, console.error);
 });
开发者ID:windwang,项目名称:angular2-app,代码行数:7,代码来源:UserEditPage.spec.ts


示例8: beforeEach

 beforeEach(done => {
   ctx.backend.connections.subscribe(conn => {
     conn.mockRespond(new Response(new BaseResponseOptions()));
   });
   ctx.init(TestCmp)
     .finally(done)
     .subscribe(() => {
       cmpDebugElement = ctx.fixture.debugElement.query(By.directive(FollowBtn));
     });
 });
开发者ID:windwang,项目名称:angular2-app,代码行数:10,代码来源:FollowBtn.spec.ts


示例9: createCmp

 function createCmp(done) {
   ctx.backend.connections.subscribe(conn => {
     conn.mockRespond(dummyResponse);
   });
   ctx.init(TestCmp)
     .finally(done)
     .subscribe(() => {
       cmpDebugElement = ctx.fixture.debugElement.query(By.directive(Feed));
     });
 }
开发者ID:mauricio1990silva,项目名称:angular2-app,代码行数:10,代码来源:Feed.spec.ts


示例10: createCmp

 function createCmp(done) {
   ctx.init(TestCmp)
     .finally(done)
     .subscribe(() => {
       cmpDebugElement = ctx.fixture.debugElement.query(By.directive(HomePage));
       if (!cmpDebugElement) return;
       userStatsDebugElement = cmpDebugElement.query(By.directive(UserStats));
       micropostNewDebugElement = cmpDebugElement.query(By.directive(MicropostNew));
       feedDebugElement = cmpDebugElement.query(By.directive(Feed));
     });
 }
开发者ID:mauricio1990silva,项目名称:angular2-app,代码行数:11,代码来源:HomePage.spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript testutils.getComponent函数代码示例发布时间:2022-05-24
下一篇:
TypeScript d3-collection.nest函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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