本文整理汇总了TypeScript中@angular/platform-browser/src/dom/debug/by.By类的典型用法代码示例。如果您正苦于以下问题:TypeScript By类的具体用法?TypeScript By怎么用?TypeScript By使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了By类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('can follow the user', () => {
const cmp:FollowBtnComponent = cmpDebugElement.componentInstance;
const testCmp:TestComponent = testCmpDebugElement.componentInstance;
spyOn(testCmp, 'doSomething');
const followBtn = cmpDebugElement.query(By.css('button'));
followBtn.nativeElement.click();
expect(cmp.canShowFollowBtn).toBeFalsy();
expect(cmp.canShowUnfollowBtn).toBeTruthy();
expect(followBtnService.follow).toHaveBeenCalledWith('1');
expect(testCmp.doSomething).toHaveBeenCalled();
});
开发者ID:Angular-Reference,项目名称:angular2-app,代码行数:11,代码来源:follow-btn.component.spec.ts
示例2: tick
tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((fixture) => {
var testComp = fixture.debugElement.componentInstance;
testComp.list = [{'name': 'SF'}, {'name': 'NYC'}, {'name': 'Buffalo'}];
testComp.selectedCity = testComp.list[1];
fixture.detectChanges();
var select = fixture.debugElement.query(By.css('select'));
var nycOption = fixture.debugElement.queryAll(By.css('option'))[1];
tick();
expect(select.nativeElement.value).toEqual('1: Object');
expect(nycOption.nativeElement.selected).toBe(true);
select.nativeElement.value = '2: Object';
dispatchEvent(select.nativeElement, 'change');
fixture.detectChanges();
tick();
expect(testComp.selectedCity['name']).toEqual('Buffalo');
});
开发者ID:ScottSWu,项目名称:angular,代码行数:20,代码来源:template_integration_spec.ts
示例3: it
it('can list users', () => {
const page:UserListComponent = cmpDebugElement.componentInstance;
expect(page.users.length).toEqual(2);
expect(page.totalPages).toEqual(1);
const el = cmpDebugElement.nativeElement;
expect(getDOM().querySelectorAll(el, 'li>a')[0].innerText).toEqual('test1');
expect(getDOM().querySelectorAll(el, 'li>a')[1].innerText).toEqual('test2');
const gravatarDebugElement = cmpDebugElement.query(By.directive(GravatarComponent));
expect(gravatarDebugElement).toBeTruthy();
expect(gravatarDebugElement.componentInstance.email).toEqual('[email protected]');
expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');
const userShowLink = cmpDebugElement.query(By.css('li>a')).nativeElement;
expect(userShowLink.getAttribute('href')).toEqual('/users/1');
const pager:PagerComponent = pagerDebugElement.componentInstance;
expect(pager.totalPages).toEqual(1);
});
开发者ID:Angular-Reference,项目名称:angular2-app,代码行数:20,代码来源:user-list.component.spec.ts
示例4: 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
示例5: fakeAsync
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
const t = `<div><form (ngSubmit)="name='updated'"></form></div>`;
let fixture = tcb.overrideTemplate(MyComp8, t).createFakeAsync(MyComp8);
tick();
fixture.debugElement.componentInstance.name = 'old';
var form = fixture.debugElement.query(By.css('form'));
dispatchEvent(form.nativeElement, 'submit');
tick();
expect(fixture.debugElement.componentInstance.name).toEqual('updated');
})));
开发者ID:ScottSWu,项目名称:angular,代码行数:13,代码来源:template_integration_spec.ts
示例6: expect
() => {
const fixture = TestBed.createComponent(SomeApp);
const cmp = fixture.debugElement.query(By.css('cmp-native')).nativeElement;
const native = cmp.shadowRoot.querySelector('.native');
expect(window.getComputedStyle(native).color).toEqual('rgb(255, 0, 0)');
const emulated = cmp.shadowRoot.querySelector('.emulated');
expect(window.getComputedStyle(emulated).color).toEqual('rgb(0, 0, 255)');
const none = cmp.shadowRoot.querySelector('.none');
expect(window.getComputedStyle(none).color).toEqual('rgb(0, 255, 0)');
});
开发者ID:DeepanParikh,项目名称:angular,代码行数:15,代码来源:dom_renderer_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
注:本文中的@angular/platform-browser/src/dom/debug/by.By类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论