當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DebugElement.query方法代碼示例

本文整理匯總了TypeScript中angular2/core.DebugElement.query方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DebugElement.query方法的具體用法?TypeScript DebugElement.query怎麽用?TypeScript DebugElement.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2/core.DebugElement的用法示例。


在下文中一共展示了DebugElement.query方法的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: 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('test1@test.com');
      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

示例3: 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('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:gtostock,項目名稱:angular2-app,代碼行數:19,代碼來源:UserList.spec.ts

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

示例5: 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('test1@test.com');
    expect(cmp.user.userStats.micropostCnt).toEqual(2);

    const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.email).toEqual('test1@test.com');
    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

示例6:

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

var debugElement: DebugElement;
var predicate;

// #docregion scope_all
debugElement.query(predicate, Scope.all);
// #enddocregion

// #docregion scope_light
debugElement.query(predicate, Scope.light);
// #enddocregion

// #docregion scope_view
debugElement.query(predicate, Scope.view);
// #enddocregion
開發者ID:Caplu,項目名稱:ng2-dribbble,代碼行數:16,代碼來源:debug_element.ts

示例7: it

    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,代碼行數:6,代碼來源:TopPage.spec.ts

示例8:

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

示例9: getChildDebugElement

/** Gets a child DebugElement by tag name. */
function getChildDebugElement(parent: DebugElement, selector: string): DebugElement {
  return parent.query(By.css(selector));
}
開發者ID:9590,項目名稱:material2,代碼行數:4,代碼來源:progress-circle.spec.ts

示例10:

import {DebugElement} from 'angular2/core';

var debugElement: DebugElement;
var predicate;

// #docregion scope_all
debugElement.query(predicate);
// #enddocregion
開發者ID:0oAimZo0,項目名稱:Angular2Learning,代碼行數:8,代碼來源:debug_element.ts


注:本文中的angular2/core.DebugElement.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。