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

TypeScript testing_internal.beforeEachBindings函数代码示例

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

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



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

示例1: describe

  describe('Compiler', () => {
    var compiler: Compiler;
    var protoViewFactorySpy;
    var someProtoView;
    var cht: CompiledHostTemplate;

    beforeEachBindings(() => {
      protoViewFactorySpy = new SpyProtoViewFactory();
      someProtoView = new AppProtoView(null, null, null, null, null, null, null);
      protoViewFactorySpy.spy('createHost').andReturn(someProtoView);
      var factory = provide(ProtoViewFactory, {useValue: protoViewFactorySpy});
      var classProvider = provide(Compiler, {useClass: Compiler_});
      var providers = [factory, classProvider];
      return providers;
    });

    beforeEach(inject([Compiler], (_compiler) => {
      compiler = _compiler;
      cht = new CompiledHostTemplate(new CompiledComponentTemplate('aCompId', null, null, null));
      reflector.registerType(SomeComponent, new ReflectionInfo([cht]));
    }));

    it('should read the template from an annotation', inject([AsyncTestCompleter], (async) => {
         compiler.compileInHost(SomeComponent)
             .then((_) => {
               expect(protoViewFactorySpy.spy('createHost')).toHaveBeenCalledWith(cht);
               async.done();
             });
       }));

    it('should clear the cache', () => {
      compiler.clearCache();
      expect(protoViewFactorySpy.spy('clearCache')).toHaveBeenCalled();
    });
  });
开发者ID:TedSander,项目名称:angular,代码行数:35,代码来源:compiler_spec.ts


示例2: describe

  describe("EventDispatcher", () => {
    beforeEachBindings(() => [
      provide(ON_WEB_WORKER, {useValue: true}),
      RenderProtoViewRefStore,
      RenderViewWithFragmentsStore
    ]);

    it("should dispatch events", inject([Serializer, AsyncTestCompleter], (serializer, async) => {
         var messageBuses = createPairedMessageBuses();
         var webWorkerEventDispatcher =
             new WebWorkerEventDispatcher(messageBuses.worker, serializer);

         var elementIndex = 15;
         var eventName = 'click';

         var eventDispatcher = new SpyEventDispatcher((elementIndex, eventName, locals) => {
           expect(elementIndex).toEqual(elementIndex);
           expect(eventName).toEqual(eventName);
           async.done();
         });

         var viewRef = new WebWorkerRenderViewRef(0);
         serializer.allocateRenderViews(0);  // serialize the ref so it's in the store
         viewRef =
             serializer.deserialize(serializer.serialize(viewRef, RenderViewRef), RenderViewRef);
         webWorkerEventDispatcher.registerEventDispatcher(viewRef, eventDispatcher);

         ObservableWrapper.callEmit(messageBuses.ui.to(EVENT_CHANNEL), {
           'viewRef': viewRef.serialize(),
           'elementIndex': elementIndex,
           'eventName': eventName,
           'locals': {'$event': {'target': {value: null}}}
         });
       }));
  });
开发者ID:kreo,项目名称:angular-2-bootstraping,代码行数:35,代码来源:event_dispatcher_spec.ts


示例3: describe

 describe('no jit', () => {
   beforeEachBindings(() => [
     provide(ChangeDetectorGenConfig,
             {useValue: new ChangeDetectorGenConfig(true, true, false, false)})
   ]);
   it('should watch element properties', () => {
     expect(detectChanges(compiler, '<div [el-prop]="someProp">'))
         .toEqual(['elementProperty(elProp)=someValue']);
   });
 });
开发者ID:hankduan,项目名称:angular,代码行数:10,代码来源:change_detector_compiler_spec.ts


示例4: describe

    describe('back button app', () => {
      beforeEachBindings(
          () => { return [provide(ROUTER_PRIMARY_COMPONENT, {useValue: HierarchyAppCmp})]; });

      it('should change the url without pushing a new history state for back navigations',
         inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {

           tcb.createAsync(HierarchyAppCmp)
               .then((rootTC) => {
                 var router = rootTC.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 = rootTC.debugElement.componentInstance.location;
                       var element = rootTC.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:,项目名称:,代码行数:51,代码来源:


示例5: main

export function main() {
  const CHANNEL = "UIMessageBroker Test Channel";
  const TEST_METHOD = "TEST_METHOD";
  const PASSED_ARG_1 = 5;
  const PASSED_ARG_2 = 'TEST';
  const RESULT = 20;
  const ID = "methodId";

  beforeEachBindings(() => [
    provide(ON_WEB_WORKER, {useValue: true}),
    RenderProtoViewRefStore,
    RenderViewWithFragmentsStore
  ]);

  describe("UIMessageBroker", () => {
    var messageBuses;

    beforeEach(() => {
      messageBuses = createPairedMessageBuses();
      messageBuses.ui.initChannel(CHANNEL);
      messageBuses.worker.initChannel(CHANNEL);
    });
    it("should call registered method with correct arguments",
       inject([Serializer], (serializer) => {
         var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL);
         broker.registerMethod(TEST_METHOD, [PRIMITIVE, PRIMITIVE], (arg1, arg2) => {
           expect(arg1).toEqual(PASSED_ARG_1);
           expect(arg2).toEqual(PASSED_ARG_2);
         });
         ObservableWrapper.callNext(messageBuses.worker.to(CHANNEL),
                                    {'method': TEST_METHOD, 'args': [PASSED_ARG_1, PASSED_ARG_2]});
       }));

    it("should return promises to the worker", inject([Serializer], (serializer) => {
         var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL);
         broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => {
           expect(arg1).toEqual(PASSED_ARG_1);
           return PromiseWrapper.wrap(() => { return RESULT; });
         });
         ObservableWrapper.callNext(messageBuses.worker.to(CHANNEL),
                                    {'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]});
         ObservableWrapper.subscribe(messageBuses.worker.from(CHANNEL), (data: any) => {
           expect(data.type).toEqual("result");
           expect(data.id).toEqual(ID);
           expect(data.value).toEqual(RESULT);
         });
       }));
  });
}
开发者ID:TedSander,项目名称:angular,代码行数:49,代码来源:service_message_broker_spec.ts


示例6: describe

  describe('element probe', function() {
    beforeEachBindings(() => [provide(APP_VIEW_POOL_CAPACITY, {useValue: 0})]);

    it('should return a TestElement from a dom element',
       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
         tcb.overrideTemplate(MyComp, '<div some-dir></div>')
             .createAsync(MyComp)
             .then((rootTestComponent) => {
               expect(inspectNativeElement(rootTestComponent.debugElement.nativeElement)
                          .componentInstance)
                   .toBeAnInstanceOf(MyComp);

               async.done();
             });
       }));

    it('should clean up whent the view is destroyed',
       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
         tcb.overrideTemplate(MyComp, '')
             .createAsync(MyComp)
             .then((rootTestComponent) => {
               rootTestComponent.destroy();
               expect(inspectNativeElement(rootTestComponent.debugElement.nativeElement))
                   .toBe(null);

               async.done();
             });

       }));

    if (!IS_DART) {
      it('should provide a global function to inspect elements',
         inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           tcb.overrideTemplate(MyComp, '')
               .createAsync(MyComp)
               .then((rootTestComponent) => {
                 expect(global['ng']['probe'](rootTestComponent.debugElement.nativeElement)
                            .componentInstance)
                     .toBeAnInstanceOf(MyComp);

                 async.done();
               });
         }));
    }
  });
开发者ID:hankduan,项目名称:angular,代码行数:45,代码来源:debug_element_view_listener_spec.ts


示例7: describe

    describe('hierarchical app', () => {
      beforeEachBindings(
          () => { return [provide(ROUTER_PRIMARY_COMPONENT, {useValue: HierarchyAppCmp})]; });

      it('should bootstrap an app with a hierarchy',
         inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {

           tcb.createAsync(HierarchyAppCmp)
               .then((fixture) => {
                 var router = fixture.debugElement.componentInstance.router;
                 router.subscribe((_) => {
                   expect(fixture.debugElement.nativeElement)
                       .toHaveText('root { parent { hello } }');
                   expect(fixture.debugElement.componentInstance.location.path())
                       .toEqual('/parent/child');
                   async.done();
                 });
                 router.navigateByUrl('/parent/child');
               });
         }));

      // TODO(btford): mock out level lower than LocationStrategy once that level exists
      xdescribe('custom app base ref', () => {
        beforeEachBindings(() => { return [provide(APP_BASE_HREF, {useValue: '/my/app'})]; });
        it('should bootstrap',
           inject([AsyncTestCompleter, TestComponentBuilder],
                  (async, tcb: TestComponentBuilder) => {

                    tcb.createAsync(HierarchyAppCmp)
                        .then((fixture) => {
                          var router = fixture.debugElement.componentInstance.router;
                          router.subscribe((_) => {
                            expect(fixture.debugElement.nativeElement)
                                .toHaveText('root { parent { hello } }');
                            expect(fixture.debugElement.componentInstance.location.path())
                                .toEqual('/my/app/parent/child');
                            async.done();
                          });
                          router.navigateByUrl('/parent/child');
                        });
                  }));
      });
    });
开发者ID:TedSander,项目名称:angular,代码行数:43,代码来源:router_integration_spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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