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


TypeScript TestComponentBuilder.createAsync方法代碼示例

本文整理匯總了TypeScript中@angular/compiler/testing.TestComponentBuilder.createAsync方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestComponentBuilder.createAsync方法的具體用法?TypeScript TestComponentBuilder.createAsync怎麽用?TypeScript TestComponentBuilder.createAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/compiler/testing.TestComponentBuilder的用法示例。


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

示例1: inject

         inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {

           tcb.createAsync(HierarchyAppCmp)
               .then((fixture) => {
                 var router = fixture.debugElement.componentInstance.router;
                 var position = 0;
                 var flipped = false;
                 var history = [
                   ['/parent/child', 'root { parent { hello } }', '/super-parent/child'],
                   ['/super-parent/child', 'root { super-parent { hello2 } }', '/parent/child'],
                   ['/parent/child', 'root { parent { hello } }', false]
                 ];

                 router.subscribe((_) => {
                   var location = fixture.debugElement.componentInstance.location;
                   var element = fixture.debugElement.nativeElement;
                   var path = location.path();

                   var entry = history[position];

                   expect(path).toEqual(entry[0]);
                   expect(element).toHaveText(entry[1]);

                   var nextUrl = entry[2];
                   if (nextUrl == false) {
                     flipped = true;
                   }

                   if (flipped && position == 0) {
                     async.done();
                     return;
                   }

                   position = position + (flipped ? -1 : 1);
                   if (flipped) {
                     location.back();
                   } else {
                     router.navigateByUrl(nextUrl);
                   }
                 });

                 router.navigateByUrl(history[0][0]);
               });
         }), 1000);
開發者ID:2blessed2bstressedbythedevilsmess,項目名稱:angular,代碼行數:44,代碼來源:bootstrap_spec.ts

示例2: it

  it('should correctly update the announce text', fakeAsyncTest(() => {
    let appFixture: ComponentFixture<TestApp> = null;

    builder.createAsync(TestApp).then(fixture => {
      appFixture = fixture;
    });

    flushMicrotasks();

    let buttonElement = appFixture.debugElement
      .query(By.css('button')).nativeElement;

    buttonElement.click();

    // This flushes our 100ms timeout for the screenreaders.
    tick(100);

    expect(liveEl.textContent).toBe('Test');
  }));
開發者ID:Angular2-BD,項目名稱:material2,代碼行數:19,代碼來源:live-announcer.spec.ts

示例3: inject

      inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        tcb.createAsync(TestComponent)
          .then((rootTC: any) => {
            rootTC.detectChanges();

            // let homeInstance = rootTC.debugElement.children[0].componentInstance;
            // let homeDOMEl = rootTC.debugElement.children[0].nativeElement;

            // expect(getDOM().querySelectorAll(homeDOMEl, 'li').length).toEqual(0);

            // homeInstance.newName = 'Minko';
            // homeInstance.addName();
            // rootTC.detectChanges();

            // expect(getDOM().querySelectorAll(homeDOMEl, 'li').length).toEqual(1);

            // expect(getDOM().querySelectorAll(homeDOMEl, 'li')[0].textContent).toEqual('Minko');
          });
      }));
開發者ID:amaurymartiny,項目名稱:gudmund,代碼行數:19,代碼來源:home.component.spec.ts

示例4: it

    it("should render User's status as card", inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb.createAsync(UserStatusCardComponent).then(componentFixture => {
            const element = componentFixture.nativeElement;

            componentFixture.componentInstance.user = new DoseAmigosUser();
            componentFixture.componentInstance.user.id = 100;
            componentFixture.componentInstance.user.name = "John Doe";
            componentFixture.componentInstance.user.lastTimeDoseTaken = new Date();
            componentFixture.componentInstance.user.nextTimeDoseScheduled = new Date();

            componentFixture.detectChanges();
            expect(
                element.querySelectorAll("ion-card").length
            ).toBe(
                1,
                "should render User's status as card"
            );
        });
    }));
開發者ID:dose-amigos,項目名稱:dose-amigos-ionic,代碼行數:19,代碼來源:user-status-card.component.spec.ts

示例5:

    [TestComponentBuilder], (tcb: TestComponentBuilder) => {
      return tcb.createAsync(TaskEdit).then(
        (componentFixture: ComponentFixture<TaskEdit>) => {
          const instance = componentFixture.debugElement.componentInstance;
          componentFixture.detectChanges();

          let controls = instance.taskEditForm.controls;
          controls.owner.updateValue('b');
          controls.description.updateValue('change task description');

          componentFixture.detectChanges();
          instance.onSubmit();

          const task = mockTasksService.getById(_id);
          chai.expect(task.owner).to.equal('b');
          chai.expect(task.description).to.equal('change task description');
        }
      );
    }
開發者ID:basadultindy,項目名稱:ngCourse2-handout,代碼行數:19,代碼來源:task-edit.spec.ts

示例6: inject

         inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
           tcb.createAsync(AppWithOutletListeners).then(fixture => {
             let appInstance = fixture.debugElement.componentInstance;
             let router = appInstance.router;

             router.subscribe((_: any /** TODO #9100 */) => {
               fixture.detectChanges();

               expect(appInstance.helloCmp).toBeAnInstanceOf(HelloCmp);
               expect(appInstance.helloCmp.message).toBe('Ahoy');

               async.done();
             });

             // TODO(juliemr): This isn't necessary for the test to pass - figure
             // out what's going on.
             // router.navigateByUrl('/rainbow(pony)');
           });
         }));
開發者ID:AudreyChao,項目名稱:angular,代碼行數:19,代碼來源:bootstrap_spec.ts

示例7: inject

            inject([TestComponentBuilder, DisqusService], (tcb: TestComponentBuilder, disqusService: DisqusService) => {
                tcb.createAsync(DemoComponent)
                    .then((fixture: ComponentFixture<DemoComponent>) => {
                        let demoComponent: DemoComponent = fixture.componentInstance;
                        let compiled: any = fixture.debugElement.nativeElement;
                       
                        spyOn(disqusService,'reset');

                        demoComponent.pageIdentifier = 'testId';
                        demoComponent.pageUrl = 'testUrl';

                        fixture.detectChanges();

                        compiled.querySelector('#btn-reset').click();

                        fixture.detectChanges();

                        expect(disqusService.reset).toHaveBeenCalledWith('testId','testUrl',true);
                    });
            })
開發者ID:eutanazie,項目名稱:angular2-disqus,代碼行數:20,代碼來源:demo.component.spec.ts

示例8: it

    it('should have the submit button enabled after form changes', async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
      return tcb.createAsync(TodoCmp).then((fixture) => {
        fixture.detectChanges();

        let instance = fixture.debugElement.componentInstance;
        let compiled = fixture.debugElement.nativeElement;

        instance.todoForm.controls.message.updateValue('abc');

        fixture.detectChanges();

        expect(compiled.getElementsByClassName('todo_button')[0].getAttribute('disabled')).toBe(null);

        instance.todoForm.controls.message.updateValue(undefined);

        fixture.detectChanges();

        expect(compiled.getElementsByClassName('todo_button')[0].getAttribute('disabled')).not.toBe(null);
      });
    })));
開發者ID:davorian,項目名稱:angular2-typescript-todo,代碼行數:20,代碼來源:todo_cmp_test.ts

示例9: it

     () => {return tcb.createAsync(PPSStatusComponent).then(fixture => {
       let component = fixture.componentInstance;
       let nativeElement = fixture.nativeElement;

       it('by hiding the message when it is empty', () => {
         expect(component.message).toEqual('');
         expect(nativeElement.querySelector('#msg')).toBe(null);
       });

       it('by showing the message when it is not null', () => {
         let newValue = 'xiexie';
         ms.AddMessage(newValue);
         fixture.detectChanges();

         expect(component.message).toEqual(newValue);
         let el = nativeElement.querySelector('#msg');
         expect(el).not.toBe(null);
         expect(el.innerHTML).toContain(newValue);
       });
     })});
開發者ID:gmadrid,項目名稱:ppsorter,代碼行數:20,代碼來源:ppsstatus.component.spec.ts

示例10: it

  it('should initialize as paused displaying the default labels', done => {
    testComponentBuilder
    .createAsync(TimerWidgetComponent)
    .then(componentFixture => {
      componentFixture.componentInstance.ngOnInit();
      componentFixture.detectChanges();

      expect(componentFixture.componentInstance.buttonLabelKey)
        .toEqual('start');

      expect(componentFixture.nativeElement
        .querySelector('button')
        .innerHTML.trim())
        .toEqual('Start Timer');

      componentFixture.destroy();
      done();
    })
      .catch(e => done.fail(e));
  });
開發者ID:Jabirfayyaz,項目名稱:learning-angular2,代碼行數:20,代碼來源:timer-widget.component.spec.ts


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