当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript testing_internal.injectAsync函数代码示例

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


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

示例1: describe

    describe('Infragistics Angular2 Popover', () => {
		it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-popover widgetId="popover" [(options)]="opts"></ig-popover></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgPopoverComponent);                 
                 
					async.done();
               });
         }));
         
         it('should initialize correctly when having a target element', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-popover widgetId="popover" [(options)]="opts"></ig-popover><input id="popover"/></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgPopoverComponent);
					async.done();
               });
         }));
         
    });
开发者ID:babually,项目名称:igniteui-angular2,代码行数:25,代码来源:popover.spec.ts

示例2: describe

  describe('About component', () => {
    it('should work',
      injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb.overrideTemplate(TestComponent, '<div><about></about></div>')
          .createAsync(TestComponent)
          .then((rootTC) => {
            rootTC.detectChanges();

            let aboutInstance = rootTC.debugElement.componentViewChildren[0].componentInstance;
            let aboutDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
            let nameListLen = function () {
              return aboutInstance.list.names.length;
            };

            expect(aboutInstance.list).toEqual(jasmine.any(NameList));
            expect(nameListLen()).toEqual(4);
            expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen());

            aboutInstance.addName({value: 'Minko'});
            rootTC.detectChanges();

            expect(nameListLen()).toEqual(5);
            expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen());

            expect(DOM.querySelectorAll(aboutDOMEl, 'li')[4].textContent).toEqual('Minko');
          });
      }));
  });
开发者ID:RobertGardner,项目名称:migrations,代码行数:28,代码来源:about_spec.ts

示例3: describe

    describe('Infragistics Angular2 HtmlEditor', () => {
		it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-html-editor widgetId="htmlEditor" [(options)]="opts" [changeDetectionInterval]="cdi" [(ngModel)]="data"></ig-html-editor></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgHtmlEditorComponent);
					async.done();
               });
         }));
         
        it('should update its content if data model changes', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-html-editor widgetId="htmlEditor" [(options)]="opts" [changeDetectionInterval]="cdi" [(ngModel)]="data"></ig-html-editor></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					fixture.componentInstance.data = "<span>Test Update</span>";
                    setTimeout(function() {
                         fixture.detectChanges();
                        expect($("#htmlEditor").igHtmlEditor("getContent", "html")).toBe("<span>Test Update</span>");
                        async.done();
                    }, 10);					
               });
         }));
         
      it('should update its content if html editor content changes', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-html-editor widgetId="htmlEditor" [(options)]="opts" [changeDetectionInterval]="cdi" [(ngModel)]="data"></ig-html-editor></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					$("#htmlEditor").igHtmlEditor("setContent", "<h1>Test</h1>", "html");
                    //simulate keyup
                    $($("#htmlEditor").find("iframe")[0]["contentWindow"].document).find("body[contenteditable=true]").trigger("keyup");
                    setTimeout(function() {
                        fixture.detectChanges();
                        expect(fixture.componentInstance.data).toBe("<h1>Test</h1>");
                        async.done();
                    }, 10);					
               });
         }));
		 
         
    });
开发者ID:babually,项目名称:igniteui-angular2,代码行数:46,代码来源:htmleditor.spec.ts

示例4: describe

    describe('Infragistics Angular2 Tree', () => {
		it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgTreeComponent);
					async.done();
               });
         }));
         
        it('should reflect changes when a record in the data changes',
            inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
            var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree></div>';
            tcb.overrideTemplate(TestComponent, template)
                .createAsync(TestComponent)
                .then((fixture) => {
                        fixture.detectChanges();
                        fixture.componentInstance.data[0].Name = "Test";                       
                        setTimeout(() => {
                            fixture.detectChanges();
                            expect($($("#tree1").igTree("nodeByIndex", 0)).children("a").text())
                            .toBe("Test");  
                            async.done();
                        }, 10);
                });
            }));
            
        it('should reflect changes when a record is added/removed from the data',
         inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
             	    fixture.detectChanges();
                     //remove item
					fixture.componentInstance.data.removeAt(0);
                      
					setTimeout(() => {					
                        fixture.detectChanges();
						expect($(fixture.debugElement.nativeElement).find("#tree1 li.ui-igtree-noderoot").length)
						.toBe(3);                      
                        //add item
                        fixture.componentInstance.data.push({ Name: "Category", ProductCategoryID: 100});
                        	setTimeout(() => {					
                            fixture.detectChanges();
                            expect($(fixture.debugElement.nativeElement).find("#tree1 li.ui-igtree-noderoot").length)
                            .toBe(4);   
                                expect($(fixture.debugElement.nativeElement).find("#tree1 li.ui-igtree-noderoot").last().children("a").text())
                                .toBe("Category");                         
                            async.done();
                        }, 10);						
					}, 10);
               });
         }));
    });
开发者ID:babually,项目名称:igniteui-angular2,代码行数:57,代码来源:igtree.spec.ts

示例5: describe

    describe('Infragistics Angular2 RadialGauge', () => {
		it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-radial-gauge  widgetId="gauge" [(options)]="opts"></ig-radial-gauge></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgRadialGaugeComponent);
					async.done();
               });
         }));         
    });
开发者ID:babually,项目名称:igniteui-angular2,代码行数:12,代码来源:igradialgauge.spec.ts

示例6: describe

  describe('Home component', () => {
    it('should work',
      injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb.overrideTemplate(TestComponent, '<div><home></home></div>')
          .createAsync(TestComponent)
          .then((rootTC) => {
            let homeDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;

            expect(DOM.querySelectorAll(homeDOMEl, 'h1')[0].textContent).toEqual('Howdy!');
          });
      }));
  });
开发者ID:RobertGardner,项目名称:migrations,代码行数:12,代码来源:home_spec.ts

示例7: describe

    describe('Infragistics Angular2 PivotDataSelector', () => {
		it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-pivot-data-selector [(widgetId)]="selId" [options]="optsGrid"></ig-pivot-data-selector></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgPivotDataSelectorComponent);
					async.done();
               });
         }));
         
    });
开发者ID:babually,项目名称:igniteui-angular2,代码行数:13,代码来源:pivotdataselector.spec.ts

示例8: describe

    describe('Infragistics Angular2 DataChart and Zoombar', () => {
		it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-data-chart  widgetId="datachart1" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-data-chart></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgDataChartComponent);
					async.done();
               });
         }));         
         
         it('Zoombar should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-data-chart  widgetId="datachart1" [(options)]="opts"></ig-data-chart><ig-zoombar [(options)]="zoombarOpts" widgetId="zoombar"></ig-zoombar></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild2).toBeAnInstanceOf(Infragistics.IgZoombarComponent);
					async.done();
               });
         }));         
    });
开发者ID:babually,项目名称:igniteui-angular2,代码行数:23,代码来源:chart.spec.ts

示例9: describe

 describe('Infragistics Angular2 Dialog', () => {
     it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
     var template = '<div><ig-dialog widgetId="dialog" [(options)]="opts"><div>Test Content</div></ig-dialog></div>';
     tcb.overrideTemplate(TestComponent, template)
         .createAsync(TestComponent)
         .then((fixture) => {
                 fixture.detectChanges();
                 expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgDialogComponent);
                 expect($(fixture.debugElement.nativeElement).find("#dialog").igDialog("content")[0].innerHTML)
                 .toBe("<div>Test Content</div>");
                 async.done();
         });
     }));
     
 });
开发者ID:babually,项目名称:igniteui-angular2,代码行数:15,代码来源:dialog.spec.ts

示例10: describe

  describe('App component', () => {

    // Support for testing component that uses Router
    beforeEachProviders(() => [
      RouteRegistry,
      DirectiveResolver,
      provide(Location, {useClass: SpyLocation}),
      provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppCmp}),
      provide(Router, {useClass: RootRouter})
    ]);

    it('should work',
      injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb.overrideTemplate(TestComponent, '<div><app></app></div>')
          .createAsync(TestComponent)
          .then(rootTC => {
            rootTC.detectChanges();
            let appDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
            expect(DOM.querySelectorAll(appDOMEl, 'section > nav > a')[1].href).toMatch(/http:\/\/localhost:\d+\/about/);
          });
      }));
  });
开发者ID:RobertGardner,项目名称:migrations,代码行数:22,代码来源:app_spec.ts


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