本文整理汇总了TypeScript中angular2/platform/common_dom.By.directive方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.directive方法的具体用法?TypeScript By.directive怎么用?TypeScript By.directive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/platform/common_dom.By
的用法示例。
在下文中一共展示了By.directive方法的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));
});
示例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();
});
示例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');
});
示例4: 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/);
});
示例5:
ctx.init(TestCmp).finally(done).subscribe(() => {
cmpDebugElement = ctx.fixture.debugElement.query(By.directive(TopPage));
});
示例6:
.subscribe(() => {
cmpDebugElement = ctx.fixture.debugElement.query(By.directive(LoginPage));
});
示例7:
.subscribe(() => {
cmpDebugElement = ctx.fixture.debugElement.query(By.directive(Gravatar));
});
示例8:
.subscribe(() => {
cmpDebugElement = ctx.fixture.debugElement.query(By.directive(UserStats));
});
示例9:
.subscribe(() => {
cmpDebugElement = ctx.fixture.debugElement.query(By.directive(FollowBtn));
});
示例10:
.subscribe(() => {
cmpDebugElement = ctx.fixture.debugElement.query(By.directive(UserEditPage));
}, console.error);