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

TypeScript aurelia-testing.ComponentTester类代码示例

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

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



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

示例1: beforeEach

 beforeEach(() => {
   model = { a: true, b: true, clicked() { } };
   component = new ComponentTester();
   component.bootstrap(aurelia => {
     aurelia.use.standardConfiguration();
     taskQueue = aurelia.container.get(TaskQueue);
   });
   component
     .withResources('test/if-test')
     .inView(`<div ift.bind="a" id="a">
               <div ift.bind="b" id="b" click.delegate="clicked()">
               </div>
             </div>`)
     .boundTo(model);
 });
开发者ID:aurelia,项目名称:templating-resources,代码行数:15,代码来源:if.spec.ts


示例2: it

  it('handles bindings with null objects', (done: () => void) => {
    const component: ComponentTester = StageComponent
      .withResources()
      .inView('<nullable-object-form></nullable-object-form>')
      .boundTo({});
    component.bootstrap(configure);

    let viewModel: NullableObjectForm;

    const renderer = { render: jasmine.createSpy() };

    component.create(bootstrap as any)
      // grab some references.
      .then(() => {
        viewModel = component.viewModel;
        viewModel.controller.addRenderer(renderer);
      })
      .then(() => expect(viewModel.controller.errors.length).toBe(0))
      .then(() => blur(viewModel.input))
      .then(() => expect(viewModel.controller.errors.length).toBe(1))
      .then(() => change(viewModel.input, 'test'))
      .then(() => expect(viewModel.controller.errors.length).toBe(1))
      .then(() => blur(viewModel.input))
      .then(() => expect(viewModel.controller.errors.length).toBe(0))
      .then(() => viewModel._obj = null)
      .then(() => blur(viewModel.input))
      .then(() => expect(viewModel.obj).toBe(null))
      .then(() => expect(viewModel.controller.errors.length).toBe(0))
      .then(() => viewModel._obj = { prop: '' })
      .then(() => blur(viewModel.input))
      .then(() => expect(viewModel.controller.errors.length).toBe(1))
      .then(() => {
        viewModel._obj = null;
        // wait for dirty-checking...
        return new Promise(resolve => setTimeout(resolve, 500));
      })
      .then(() => expect(viewModel.controller.errors.length).toBe(0))

      // cleanup and finish.
      .then(() => component.dispose())
      .then(done);
  });
开发者ID:StrahilKazlachev,项目名称:validation,代码行数:42,代码来源:null-object.ts


示例3: configure

  const stageTest = (validationErrors: string, supplyControllerToViewModel?: boolean) => {
    const form: string = `
      <template>
        <form novalidate autocomplete='off' ${validationErrors}>
          <input ref='standardInput' type='text' value.bind='standardProp & validateOnBlur'>
        </form>
      </template>`;

    parentViewModel.form = form;

    component = StageComponent
      .withResources()
      // tslint:disable-next-line:max-line-length
      .inView(`<compose containerless view-model="./dist/test/test/resources/validation-errors-form-one" model.bind="{ form: form, controller: controller }"></compose>`)
      // tslint:enable-next-line:max-line-length
      .boundTo(parentViewModel);

    const myConfigure = (aurelia: Aurelia) => {
      const config = configure(aurelia);
      container = aurelia.container;
      return config;
    };

    component.bootstrap(myConfigure);

    /*
      at this point validation plugin has not yet been initialized, not until in component.create()
    */
    if (supplyControllerToViewModel) {
      /*
        the viewmodel is going to call this in created().
        at that point the validation plugin will have been initialized and bind() will
        not yet have been executed.
      */
      parentViewModel.controller = () => {
        const factory = container.get(ValidationControllerFactory);
        const controller = factory.createForCurrentScope();
        parentViewModel.theController = controller;
        return controller;
      };
    }

    return component.create(bootstrap as any)
      .then(() => {
        // we get here after the viewmodel's bind().
        viewModel = component.viewModel.currentViewModel;
      });
  };
开发者ID:doktordirk,项目名称:validation,代码行数:48,代码来源:validation-errors-custom-attribute.ts


示例4: it

    it('loads layouts for a named viewport', done => {
      component = withNamedViewport({
        viewPorts: {
          viewport1: {
            moduleId: 'test/routes/route-2',
            layoutViewModel: 'test/routes/layout-1'
          }
        }
      });

      component.create(bootstrap)
        .then(() => {
          expect(component.element.querySelectorAll('.route-1').length).toBe(1);
          expect(component.element.querySelectorAll('.route-2').length).toBe(0);
          expect(component.element.querySelectorAll('.layout-1').length).toBe(0);
          return component.viewModel.router.navigate('route');
        })
        .then(wait)
        .then(() => {
          expect(component.element.querySelectorAll('.route-1').length).toBe(0);
          expect(component.element.querySelectorAll('.route-2:not(.view-only)').length).toBe(1);
          expect(component.element.querySelectorAll('.layout-1:not(.view-only)').length).toBe(1);
          done();
        })
        .catch(done.fail);
    });
开发者ID:aurelia,项目名称:templating-router,代码行数:26,代码来源:router-view.spec.ts


示例5: it

 it(`throws when binding "route" to invalid route name: "${routeName}"`, async () => {
   component = createComponent(`<a route-href.bind="name"></a><router-view></router-view>`, undefined, { name: routeName });
   const errors: Set<any> = new Set();
   const spy = spyOn(Logger.prototype, 'error').and.callFake((err: any) => errors.add(err));
   await component.create(bootstrap);
   expect(spy.calls.count()).toBeGreaterThan(0);
   expect(Array.from(errors).some(err => ('' + err).includes(`A route with name '${routeName}' could not be found.`)));
 });
开发者ID:aurelia,项目名称:templating-router,代码行数:8,代码来源:route-href.1.spec.ts


示例6: afterEach

 afterEach(() => {
   if (component) {
     const appRouter = component.viewModel.router as AppRouter;
     appRouter.reset();
     appRouter.deactivate();
     component.dispose();
     component = undefined;
   }
   location.hash = '';
   removeDebugLogging();
 });
开发者ID:aurelia,项目名称:templating-router,代码行数:11,代码来源:route-href.1.spec.ts


示例7: it

  it('should use route as primary property', done => {
    component = StageComponent
      .withResources(PLATFORM.moduleName('src/route-href'))
      .inView('<a route-href.bind="name"></a>')
      .boundTo({ name: 'b' });

    configure(component);

    component.create(bootstrap)
      .then(() => {
        expect(component.viewModel.route).toBe('b');
        done();
      });
  });
开发者ID:aurelia,项目名称:templating-router,代码行数:14,代码来源:route-href.spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript aurelia-testing.StageComponent类代码示例发布时间:2022-05-25
下一篇:
TypeScript aurelia-templating.ViewSlot类代码示例发布时间: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