• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript testing.tick函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中angular2/testing.tick函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tick函数的具体用法?TypeScript tick怎么用?TypeScript tick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tick函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should login', inject([TestComponentBuilder], fakeAsync((tcb:TestComponentBuilder) => {
    let fixture;
    tcb
      // https://github.com/angular/angular/issues/2835
      .overrideTemplate(TaLogin, `
        <form>
          <input type="text" #username>
          <button (click)="loginSubmit(username)">Find user</button>
        </form>
      `)
      .createAsync(TaLogin).then((rootFixture) => {
        fixture = rootFixture;
      });

    tick();

    let componentInstance = fixture.componentInstance;
    let element = fixture.nativeElement;
    let username;

    componentInstance.login.subscribe((value) => {
      username = value;
    });

    element.querySelector('input').value = 'cironunes';
    element.querySelector('button').click();
    tick();
    expect(username).toBe('cironunes');
  })));
开发者ID:cironunes,项目名称:ng2-tests,代码行数:29,代码来源:ta-login.spec.ts


示例2: 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


示例3: createComponent

      createComponent(tcb).then((fixture) => {
        input.value = 'ABC';
        dispatchEvent(input, 'input');
        tick();

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

        expect(fakeConsole._logs).toContain('you submitted value: ABC');
      });
开发者ID:Gitjerryzhong,项目名称:angular2,代码行数:11,代码来源:demo_form_with_events.spec.ts


示例4: tick

                    .then((controlsInstance: PaginationControlsCmp) => {
                        testCmpInstance.config.currentPage = 1;
                        fixture.detectChanges();
                        tick();

                        expect(controlsInstance.api.isLastPage()).toBe(false);

                        testCmpInstance.config.currentPage = 10;
                        fixture.detectChanges();
                        tick();

                        expect(controlsInstance.api.isLastPage()).toBe(true);
                    });
开发者ID:davidfang,项目名称:ng2-pagination,代码行数:13,代码来源:pagination-controls-cmp.spec.ts


示例5: it

  it('should accept pin (with fakeAsync)', inject([TestComponentBuilder], fakeAsync((tcb) => {
    var fixture;
    tcb.createAsync(GreetingComponent).then((rootFixture) => {
      fixture = rootFixture });
    tick();

    var compiled = fixture.debugElement.nativeElement;
    compiled.querySelector('button').click();

    tick();
    fixture.detectChanges();
    expect(compiled.querySelector('h3')).toHaveText('Status: Welcome!');
  })));
开发者ID:SBero,项目名称:ng2-test-seed,代码行数:13,代码来源:greeting-component_test.ts


示例6: it

      it('should load operations and schema', inject([], fakeAsync(() => {
        mockBackend.connections.subscribe(c => {
          expect(c.request.url).toBe('http://localhost:8000/apidoc');
          let response = new ResponseOptions({
            body: {
              'hydra:title': 'Hydra API Test',
              'hydra:supportedClass': [
                {'@id': 'http://schema.org/Person'},
                {'@id': 'http://schema.org/BlogPosting'},
                {'@id': '#Entrypoint'},
                {'@id': '#ConstraintViolation'},
                {'@id': '#ConstraintViolationList'}
              ]
            }
          });
          c.mockRespond(new Response(response));
        });

        spyOn(schemaService, '_loadCollectionOperations');
        spyOn(schemaService, '_loadSingleOperations');
        spyOn(schemaService, '_loadSchema');

        schemaService._loadDocumentation();
        tick();

        expect(schemaService._loadCollectionOperations).toHaveBeenCalled();
        expect(schemaService._loadSingleOperations).toHaveBeenCalled();
        expect(schemaService._loadSchema).toHaveBeenCalled();
      })));
开发者ID:gitter-badger,项目名称:hydra-admin,代码行数:29,代码来源:schema.spec.ts


示例7: it

    it('should set the user', inject([Ng2TestsApp], fakeAsync((app: Ng2TestsApp) => {
      app.findUser('nonexistent');
      tick();

      expect(app.user).toBe(null);
      expect(app.msg).toBe('User not found');
    })));
开发者ID:cironunes,项目名称:ng2-tests,代码行数:7,代码来源:ng2-tests.spec.ts


示例8: fakeAsync

      fakeAsync((tasksService, mockBackend) => {

        mockBackend.connections.subscribe( conn => {

          chai.expect(conn.request.url).to.be.oneOf([
            'http://ngcourse.herokuapp.com/api/v1/tasks',
            'http://ngcourse.herokuapp.com/api/v1/tasks/1'
          ]);
          chai.expect(conn.request.method).to.be.oneOf([
            RequestMethod.Get,
            RequestMethod.Post,
            RequestMethod.Delete,
            RequestMethod.Put
          ]);

          if (conn.request.url ===
            'http://ngcourse.herokuapp.com/api/v1/tasks' &&
            conn.request.method === RequestMethod.Get) {
              let response = new ResponseOptions({body: mockTasksResponse});
              conn.mockRespond(new Response(response));
              return;
          }

          let response = new ResponseOptions({body: mockResponseBody});
          conn.mockRespond(new Response(response));
        });

        tasksService.fetch();
        tick();
        callback(tasksService);
      }
开发者ID:ManuCutillas,项目名称:ngCourse2,代码行数:31,代码来源:tasks-service.spec.ts


示例9: spyOn

                    .then((controlsInstance: PaginationControlsCmp) => {
                        spyOn(testCmpInstance, 'pageChanged');
                        controlsInstance.api.next();
                        tick();

                        expect(testCmpInstance.pageChanged).toHaveBeenCalledWith(3);
                    });
开发者ID:davidfang,项目名称:ng2-pagination,代码行数:7,代码来源:pagination-controls-cmp.spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript testing.withProviders函数代码示例发布时间:2022-05-25
下一篇:
TypeScript testing.setBaseTestProviders函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap