本文整理汇总了TypeScript中angular2/src/platform/dom/dom_adapter.DOM.querySelectorAll方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOM.querySelectorAll方法的具体用法?TypeScript DOM.querySelectorAll怎么用?TypeScript DOM.querySelectorAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/platform/dom/dom_adapter.DOM
的用法示例。
在下文中一共展示了DOM.querySelectorAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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();
});
示例2: expect
.then((fixture) => {
fixture.debugElement.componentInstance.booleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(fixture.debugElement.nativeElement).toHaveText('');
fixture.debugElement.componentInstance.booleanCondition = true;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(fixture.debugElement.nativeElement).toHaveText('hello');
fixture.debugElement.componentInstance.nestedBooleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(fixture.debugElement.nativeElement).toHaveText('');
fixture.debugElement.componentInstance.nestedBooleanCondition = true;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(fixture.debugElement.nativeElement).toHaveText('hello');
fixture.debugElement.componentInstance.booleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(fixture.debugElement.nativeElement).toHaveText('');
async.done();
});
示例3: expect
.then(rootTC => {
rootTC.detectChanges();
let appDOMEl = rootTC.debugElement.children[0].nativeElement;
expect(DOM.querySelectorAll(appDOMEl, 'sd-app > sd-navbar > nav > a')[0].href).toMatch(/http:\/\/localhost/);
expect(DOM.querySelectorAll(appDOMEl, 'sd-app > sd-navbar > nav > a')[0].textContent).toEqual('PRODUCTS');
});
示例4: expect
tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(fixture.debugElement.nativeElement).toHaveText('hello2');
async.done();
});
示例5: it
it('can show list of posts', () => {
const cmp:MicropostList = cmpDebugElement.componentInstance;
expect(cmp.posts.length).toEqual(2);
const el = cmpDebugElement.nativeElement;
expect(DOM.querySelectorAll(el, 'li>.content').length).toEqual(2);
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();
});
示例6: function
.then((rootTC) => {
rootTC.detectChanges();
let aboutInstance = rootTC.debugElement.componentViewChildren[0].componentInstance;
let aboutDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
let nameListLen = function () {
return aboutInstance.list.names.length;
};
expect(aboutInstance.list).toEqual(jasmine.any(NameList));
expect(nameListLen()).toEqual(4);
expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen());
aboutInstance.addName({value: 'Minko'});
rootTC.detectChanges();
expect(nameListLen()).toEqual(5);
expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen());
expect(DOM.querySelectorAll(aboutDOMEl, 'li')[4].textContent).toEqual('Minko');
});