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

TypeScript core.DebugElement类代码示例

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

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



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

示例1:

 .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:windwang,项目名称:angular2-app,代码行数:7,代码来源:HomePage.spec.ts


示例2: 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:gtostock,项目名称:angular2-app,代码行数:59,代码来源:HomePage.spec.ts


示例3: setup

        return setup(template).then((fixture: ComponentFixture) => {
          let element: DebugElement = fixture.debugElement.query(By.css('[md-ink]'));
          let save = Ink.rippleEvent;
          let fired = false;
          Ink.rippleEvent = () => {
            fired = true;
            return Promise.resolve();
          };

          let event = DOM.createEvent('mouse');
          element.triggerEventHandler('mousedown', event);

          expect(fired).toBe(false);
          Ink.rippleEvent = save;
        });
开发者ID:LiTiang,项目名称:ng2-material,代码行数:15,代码来源:ink_spec.ts


示例4: it

    it('can show feed', () => {
      const cmp:Feed = cmpDebugElement.componentInstance;
      expect(cmp.feed.length).toEqual(2);

      const el = cmpDebugElement.nativeElement;
      expect(DOM.querySelectorAll(el, 'li .content').length).toEqual(2);

      const avatarLink = DOM.querySelector(el, 'li>a');
      expect(avatarLink.getAttribute('href')).toEqual('/users/1');

      const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
      expect(gravatarDebugElement).toBeTruthy();
      expect(gravatarDebugElement.componentInstance.email).toEqual('[email protected]');
      expect(gravatarDebugElement.componentInstance.alt).toEqual('test user1');

      const userLink = DOM.querySelector(el, '.user>a');
      expect(userLink).toHaveText('test user1');
      expect(userLink.getAttribute('href')).toEqual('/users/1');

      const content = DOM.querySelector(el, '.content');
      expect(content).toHaveText('content1');

      const timestamp = DOM.querySelector(el, '.timestamp');
      expect(timestamp.innerText).toMatch(/1 day ago/);

      const deleteLinks = DOM.querySelectorAll(el, '.delete');
      expect(deleteLinks[0]).toBeTruthy();
      expect(deleteLinks[1]).toBeFalsy();
    });
开发者ID:windwang,项目名称:angular2-app,代码行数:29,代码来源:Feed.spec.ts


示例5: it

  it('can be shown', () => {
    ctx.fixture.detectChanges();

    expect(cmpDebugElement).toBeTruthy();

    const cmp:UserList = cmpDebugElement.componentInstance;
    expect(cmp.users.length).toEqual(2);

    expect(DOM.querySelectorAll(cmpDebugElement.nativeElement, '.users>li').length).toEqual(2);

    const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');
    expect(gravatarDebugElement.componentInstance.email).toEqual('[email protected]');

    const userLink:HTMLElement = cmpDebugElement.query(By.css('.users>li>a')).nativeElement;
    expect(userLink.innerText).toEqual('test1');
    expect(userLink.getAttribute('href')).toEqual('/users/1');
  });
开发者ID:gtostock,项目名称:angular2-app,代码行数:19,代码来源:UserList.spec.ts


示例6: it

    it('can follow', () => {
      const cmp:FollowBtn = cmpDebugElement.componentInstance;
      cmp.isFollowedByMe = false;
      ctx.fixture.detectChanges();

      const followBtn = cmpDebugElement.query(By.css('.follow-btn')).nativeElement;
      expect(followBtn).toHaveText('Follow');

      followBtn.click();
      expect(cmp.isFollowedByMe).toBeTruthy();
      expect(relationshipService.follow).toHaveBeenCalledWith('1');
    });
开发者ID:windwang,项目名称:angular2-app,代码行数:12,代码来源:FollowBtn.spec.ts


示例7: describe

describe('relationship.UserList', () => {

  var ctx:TestContext;
  var cmpDebugElement: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(UserList));
      });
  }

  beforeEach(createCmp);

  it('can be shown', () => {
    ctx.fixture.detectChanges();

    expect(cmpDebugElement).toBeTruthy();

    const cmp:UserList = cmpDebugElement.componentInstance;
    expect(cmp.users.length).toEqual(2);

    expect(DOM.querySelectorAll(cmpDebugElement.nativeElement, '.users>li').length).toEqual(2);

    const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');
    expect(gravatarDebugElement.componentInstance.email).toEqual('[email protected]');

    const userLink:HTMLElement = cmpDebugElement.query(By.css('.users>li>a')).nativeElement;
    expect(userLink.innerText).toEqual('test1');
    expect(userLink.getAttribute('href')).toEqual('/users/1');
  });

  it('can load more', () => {
    const cmp:UserList = cmpDebugElement.componentInstance;
    const moreBtn = DOM.querySelector(cmpDebugElement.nativeElement, '.moreBtn');
    spyOn(cmp, 'listProvider').and.callThrough();
    moreBtn.click();
    expect(cmp.users.length).toEqual(4);
    expect(cmp.listProvider).toHaveBeenCalledWith({maxId: 100, count: 5});
  });

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


示例8: it

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

    const cmp:UserStats = cmpDebugElement.componentInstance;
    expect(cmp.userId).toEqual('1');
    expect(cmp.user).toBeTruthy();
    expect(cmp.user.id).toEqual(1);
    expect(cmp.user.email).toEqual('[email protected]');
    expect(cmp.user.userStats.micropostCnt).toEqual(2);

    const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.email).toEqual('[email protected]');
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');

    const el = cmpDebugElement.nativeElement;
    const header = DOM.querySelector(el, 'h2');
    expect(header.innerText).toMatch(/test1/);

    const profileLink = DOM.querySelector(el, 'a.profile-link');
    expect(profileLink).toBeTruthy();
    expect(profileLink.getAttribute('href')).toEqual('/users/1');

    const postCnt = DOM.querySelector(el, '.microposts');
    expect(postCnt).toBeTruthy();
    expect(postCnt.innerText).toMatch(/2 microposts/);

    const followingsLink = DOM.querySelector(el, 'a.followings');
    expect(followingsLink).toBeTruthy();
    expect(followingsLink.getAttribute('href')).toEqual('/users/1/followings');
    expect(followingsLink.innerText).toMatch(/3[\s\S]*?followings/);

    const followersLink = DOM.querySelector(el, 'a.followers');
    expect(followersLink).toBeTruthy();
    expect(followersLink.getAttribute('href')).toEqual('/users/1/followers');
    expect(followersLink.innerText).toMatch(/4[\s\S]*?followers/);
  });
开发者ID:gtostock,项目名称:angular2-app,代码行数:37,代码来源:UserStats.spec.ts


示例9: describe

  describe('TopPage', () => {

    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(TopPage));
      });
    });

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

      const signupLink = cmpDebugElement.query(By.css('a')).nativeElement;
      expect(signupLink.getAttribute('href')).toEqual('/signup');
    });

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


示例10:

import {By} from 'angular2/platform/browser';
import {DebugElement, Scope} from 'angular2/core';

var debugElement: DebugElement;
class MyDirective {}

// #docregion by_all
debugElement.query(By.all(), Scope.all);
// #enddocregion

// #docregion by_css
debugElement.query(By.css('[attribute]'), Scope.all);
// #enddocregion

// #docregion by_directive
debugElement.query(By.directive(MyDirective), Scope.all);
// #enddocregion
开发者ID:Caplu,项目名称:ng2-dribbble,代码行数:17,代码来源:by.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.DirectiveResolver类代码示例发布时间:2022-05-25
下一篇:
TypeScript core.ComponentRef类代码示例发布时间: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