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


TypeScript By.directive方法代码示例

本文整理汇总了TypeScript中@angular/platform-browser/src/dom/debug/by.By.directive方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.directive方法的具体用法?TypeScript By.directive怎么用?TypeScript By.directive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/platform-browser/src/dom/debug/by.By的用法示例。


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

示例1:

 return router.navigate(['/users', '1']).then(() => {
   cmpDebugElement = fixture.debugElement.query(By.directive(UserShowComponent));
   userStatsDebugElement = cmpDebugElement.query(By.directive(UserStatsComponent));
   followBtnDebugElement = cmpDebugElement.query(By.directive(FollowBtnComponent));
   micropostListDebugElement = cmpDebugElement.query(By.directive(MicropostListComponent));
   fixture.detectChanges();
 });
开发者ID:Angular-Reference,项目名称:angular2-app,代码行数:7,代码来源:user-show.component.spec.ts

示例2:

 .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,代码行数:7,代码来源:HomePage.spec.ts

示例3:

 .then((fixture:ComponentFixture<any>) => {
   cmpDebugElement = fixture.debugElement.query(By.directive(HomeComponent));
   userStatsDebugElement = cmpDebugElement.query(By.directive(UserStatsComponent));
   micropostNewDebugElement = cmpDebugElement.query(By.directive(MicropostNewComponent));
   feedDebugElement = cmpDebugElement.query(By.directive(FeedComponent));
   fixture.detectChanges();
 });
开发者ID:cipengxu,项目名称:angular2-app,代码行数:7,代码来源:home.component.spec.ts

示例4: it

  it('can show feed', () => {
    expect(cmpDebugElement).toBeTruthy();

    const cmp:Feed = cmpDebugElement.componentInstance;
    expect(cmp.feed.length).toEqual(2);

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

    const avatarLink = getDOM().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('test1@test.com');
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test user1');

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

    const content = getDOM().querySelector(el, '.content');
    expect(content.innerHTML).toEqual('content1');

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

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

示例5: it

 it('list another page when page was changed', fakeAsync(() => {
   pagerDebugElement.triggerEventHandler('pageChanged', {page: 2});
   advance(fixture);
   cmpDebugElement = fixture.debugElement.query(By.directive(UserListComponent));
   const cmp:UserListComponent = cmpDebugElement.componentInstance;
   expect(cmp.page).toEqual(2);
 }));
开发者ID:Angular-Reference,项目名称:angular2-app,代码行数:7,代码来源:user-list.component.spec.ts

示例6: it

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

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

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

    const gravatarDebugElement = cmpDebugElement.query(By.directive(GravatarComponent));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');
    expect(gravatarDebugElement.componentInstance.email).toEqual('test1@test.com');

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

示例7: it

      it('should support dotted selectors', async(() => {
           @Directive({selector: '[dot.name]'})
           class MyDir {
             @Input('dot.name') value: string;
           }

           TestBed.configureTestingModule({
             declarations: [
               MyDir,
               TestComponent,
             ],
           });

           const template = `<div [dot.name]="'foo'"></div>`;
           fixture = createTestComponent(template);
           fixture.detectChanges();
           const myDir = fixture.debugElement.query(By.directive(MyDir)).injector.get(MyDir);
           expect(myDir.value).toEqual('foo');
         }));
开发者ID:JohnnyQQQQ,项目名称:angular,代码行数:19,代码来源:integration_spec.ts

示例8: expect

             tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((fixture) => {
               fixture.debugElement.componentInstance.name = '';
               fixture.detectChanges();

               const form = fixture.debugElement.query(By.css('form')).nativeElement;
               const modelGroup =
                   fixture.debugElement.query(By.directive(NgModelGroup)).nativeElement;
               const input = fixture.debugElement.query(By.css('input')).nativeElement;

               // ngModelGroup creates its control asynchronously
               fixture.whenStable().then(() => {
                 fixture.detectChanges();
                 expect(sortedClassList(modelGroup)).toEqual([
                   'ng-invalid', 'ng-pristine', 'ng-untouched'
                 ]);

                 expect(sortedClassList(form)).toEqual([
                   'ng-invalid', 'ng-pristine', 'ng-untouched'
                 ]);

                 dispatchEvent(input, 'blur');
                 fixture.detectChanges();

                 expect(sortedClassList(modelGroup)).toEqual([
                   'ng-invalid', 'ng-pristine', 'ng-touched'
                 ]);
                 expect(sortedClassList(form)).toEqual(['ng-invalid', 'ng-pristine', 'ng-touched']);

                 input.value = 'updatedValue';
                 dispatchEvent(input, 'input');
                 fixture.detectChanges();

                 expect(sortedClassList(modelGroup)).toEqual([
                   'ng-dirty', 'ng-touched', 'ng-valid'
                 ]);
                 expect(sortedClassList(form)).toEqual(['ng-dirty', 'ng-touched', 'ng-valid']);
               });
               async.done();
             });
开发者ID:ScottSWu,项目名称:angular,代码行数:39,代码来源:template_integration_spec.ts

示例9: it

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

    const cmp:UserStatsComponent = cmpDebugElement.componentInstance;
    expect(cmp.userId).toEqual('1');
    expect(cmp.user).toBeTruthy();
    expect(cmp.user.id).toEqual(1);
    expect(cmp.user.email).toEqual('test1@test.com');
    expect(cmp.user.userStats.micropostCnt).toEqual(2);

    const gravatarDebugElement = cmpDebugElement.query(By.directive(GravatarComponent));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.email).toEqual('test1@test.com');
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');

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

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

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

    const followingsLink = getDOM().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 = getDOM().querySelector(el, 'a.followers');
    expect(followersLink).toBeTruthy();
    expect(followersLink.getAttribute('href')).toEqual('/users/1/followers');
    expect(followersLink.innerText).toMatch(/4[\s\S]*?followers/);
  });
开发者ID:Angular-Reference,项目名称:angular2-app,代码行数:37,代码来源:user-stats.component.spec.ts


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