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


TypeScript DOM.querySelectorAll方法代码示例

本文整理汇总了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();
    });
开发者ID:windwang,项目名称:angular2-app,代码行数:29,代码来源:Feed.spec.ts

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

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

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

示例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();
    });
开发者ID:windwang,项目名称:angular2-app,代码行数:17,代码来源:MicropostList.spec.ts

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


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