當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript browser.By類代碼示例

本文整理匯總了TypeScript中angular2/platform/browser.By的典型用法代碼示例。如果您正苦於以下問題:TypeScript By類的具體用法?TypeScript By怎麽用?TypeScript By使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了By類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: dispatchEvent

      tcb.createAsync(DemoFormWithEvents).then((fixture) => {
        let el = fixture.debugElement.nativeElement;
        let input = fixture.debugElement.query(By.css("input")).nativeElement;
        let form = fixture.debugElement.query(By.css("form")).nativeElement;
        fixture.detectChanges();

        input.value = '';
        dispatchEvent(input, 'input');
        fixture.detectChanges();
        tick();

        // no value on sku field, all error messages are displayed
        let msgs = el.querySelectorAll('.ui.error.message');
        expect(msgs[0]).toHaveText('SKU is invalid');
        expect(msgs[1]).toHaveText('SKU is required');

        // displays no errors when sku has a value
        input.value = 'XYZ';
        dispatchEvent(input, 'input');
        fixture.detectChanges();
        tick()

        msgs = el.querySelectorAll('.ui.error.message');
        expect(msgs.length).toEqual(0);

        fixture.detectChanges();
        dispatchEvent(form, 'submit');
        tick();

        // checks for the form submitted message
        expect(fakeConsole._logs).toContain('you submitted value: XYZ');
      });
開發者ID:Gitjerryzhong,項目名稱:angular2,代碼行數:32,代碼來源:demo_form_with_events_bad.spec.ts

示例2:

 .then((fixture: ComponentFixture) => {
   element = fixture.debugElement.nativeElement;
   form = fixture.debugElement.query(By.css('form')).nativeElement;
   usernameInput = fixture.debugElement.query(By.css('#username')).nativeElement;
   emailInput = fixture.debugElement.query(By.css('#email')).nativeElement;
   fixture.detectChanges();
   return fixture;
 });
開發者ID:aneagoie,項目名稱:angular2-unit-test-app,代碼行數:8,代碼來源:create-user.component.spec.ts

示例3:

    return tcb.createAsync(DemoFormWithEvents).then((fixture) => {
      el = fixture.debugElement.nativeElement;
      input = fixture.debugElement.query(By.css("input")).nativeElement;
      form = fixture.debugElement.query(By.css("form")).nativeElement;
      fixture.detectChanges();

      return fixture;
    });
開發者ID:Gitjerryzhong,項目名稱:angular2,代碼行數:8,代碼來源:demo_form_with_events.spec.ts

示例4:

 .then((fixture: ComponentFixture) => {
   let element = fixture.debugElement.nativeElement;
   let form = fixture.debugElement.query(By.css('form')).nativeElement;
   let usernameInput = fixture.debugElement.query(By.css('#username')).nativeElement;
   let emailInput = fixture.debugElement.query(By.css('#email')).nativeElement;
   fixture.detectChanges();
   return {element, form, usernameInput, emailInput, fixture};
 });
開發者ID:TNNSon,項目名稱:angular2-unit-test-app,代碼行數:8,代碼來源:create-user.component.spec.ts

示例5: expect

        .then((fixture) => {
          let button = fixture.debugElement.query(By.css('md-radio-button'));
          let input = button.query(By.css('input'));

          fixture.detectChanges();
          expect(button.componentInstance.checked).toBe(false);

          let event = createEvent('change');
          input.nativeElement.dispatchEvent(event);
          expect(button.componentInstance.checked).toBe(true);
        }).then(done);
開發者ID:tkhemani,項目名稱:a2MaterialAlpha,代碼行數:11,代碼來源:radio_button.spec.ts

示例6:

 return prep.then((fixture: ComponentFixture) => {
   fixture.detectChanges();
   let debug = fixture.debugElement.query(By.css('md-sidenav'));
   let cdebug = fixture.debugElement.query(By.css('md-sidenav-container'));
   return {
     fixture: fixture,
     component: debug.componentInstance,
     debug: debug,
     cdebug: cdebug,
     container: cdebug ? cdebug.componentInstance : null
   };
 }).catch(console.error.bind(console));
開發者ID:dmacfarlane,項目名稱:ng2-material,代碼行數:12,代碼來源:sidenav_spec.ts

示例7: expect

          .then((fixture) => {
            fixture.detectChanges();
            let progressElement = fixture.debugElement.query(By.css('md-progress-bar'));
            let progressComponent = progressElement.componentInstance;

            expect(progressComponent.primaryTransform()).toBe('scaleX(0)');
            expect(progressComponent.bufferTransform()).toBe(undefined);

            progressComponent.value = 40;
            expect(progressComponent.primaryTransform()).toBe('scaleX(0.4)');
            expect(progressComponent.bufferTransform()).toBe(undefined);

            progressComponent.value = 35;
            progressComponent.bufferValue = 55;
            expect(progressComponent.primaryTransform()).toBe('scaleX(0.35)');
            expect(progressComponent.bufferTransform()).toBe(undefined);

            progressComponent.mode = 'buffer';
            expect(progressComponent.primaryTransform()).toBe('scaleX(0.35)');
            expect(progressComponent.bufferTransform()).toBe('scaleX(0.55)');


            progressComponent.value = 60;
            progressComponent.bufferValue = 60;
            expect(progressComponent.primaryTransform()).toBe('scaleX(0.6)');
            expect(progressComponent.bufferTransform()).toBe('scaleX(0.6)');
            done();
          });
開發者ID:9590,項目名稱:material2,代碼行數:28,代碼來源:progress-bar.spec.ts


注:本文中的angular2/platform/browser.By類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。