本文整理汇总了TypeScript中@angular/platform-browser/src/dom/debug/by.By.css方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.css方法的具体用法?TypeScript By.css怎么用?TypeScript By.css使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/platform-browser/src/dom/debug/by.By
的用法示例。
在下文中一共展示了By.css方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: tick
tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((fixture) => {
fixture.detectChanges();
const form = fixture.debugElement.children[0].injector.get(NgForm).form;
fixture.detectChanges();
tick();
form.find('login').valueChanges.subscribe(
() => { expect(form.find('login').dirty).toBe(true); });
const loginEl = fixture.debugElement.query(By.css('input')).nativeElement;
loginEl.value = 'newValue';
dispatchEvent(loginEl, 'input');
});
示例2: 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)');
});
示例3: 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');
});
示例4: fakeAsync
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
const t = `<div><input type="text" [(ngModel)]="name"></div>`;
let fixture = tcb.overrideTemplate(MyComp8, t).createFakeAsync(MyComp8);
tick();
fixture.debugElement.componentInstance.name = 'oldValue';
fixture.detectChanges();
var input = fixture.debugElement.query(By.css('input')).nativeElement;
tick();
expect(input.value).toEqual('oldValue');
input.value = 'updatedValue';
dispatchEvent(input, 'input');
tick();
expect(fixture.debugElement.componentInstance.name).toEqual('updatedValue');
})));
示例5: 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('test1@test.com');
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);
});
示例6: expect
tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((fixture) => {
fixture.debugElement.componentInstance.name = '';
fixture.detectChanges();
var input = fixture.debugElement.query(By.css('input')).nativeElement;
expect(sortedClassList(input)).toEqual([
'ng-invalid', 'ng-pristine', 'ng-untouched'
]);
dispatchEvent(input, 'blur');
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(['ng-invalid', 'ng-pristine', 'ng-touched']);
input.value = 'updatedValue';
dispatchEvent(input, 'input');
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(['ng-dirty', 'ng-touched', 'ng-valid']);
async.done();
});
示例7: expect
() => {
TestBed.overrideComponent(CmpEncapsulationNative, {
set: {
template:
'<div class="native"></div><cmp-emulated></cmp-emulated><cmp-none></cmp-none>'
}
});
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)');
});