当前位置: 首页>>代码示例>>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;未经允许,请勿转载。