当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript By.css方法代码示例

本文整理汇总了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');
         });
开发者ID:ScottSWu,项目名称:angular,代码行数:15,代码来源:template_integration_spec.ts

示例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)');
         });
开发者ID:DeepanParikh,项目名称:angular,代码行数:15,代码来源:dom_renderer_spec.ts

示例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');
  });
开发者ID:Angular-Reference,项目名称:angular2-app,代码行数:17,代码来源:related-user-list.component.spec.ts

示例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');
       })));
开发者ID:ScottSWu,项目名称:angular,代码行数:19,代码来源:template_integration_spec.ts

示例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);
  });
开发者ID:Angular-Reference,项目名称:angular2-app,代码行数:20,代码来源:user-list.component.spec.ts

示例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();
             });
开发者ID:ScottSWu,项目名称:angular,代码行数:21,代码来源:template_integration_spec.ts

示例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)');
         });
开发者ID:acramatte,项目名称:angular,代码行数:22,代码来源:dom_renderer_spec.ts


注:本文中的@angular/platform-browser/src/dom/debug/by.By.css方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。