本文整理汇总了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();
});
}));
});
示例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');
});
}));
});
示例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);
});
}));
});
示例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);
});
}));
});
示例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();
});
}));
});
示例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!');
});
}));
});
示例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();
});
}));
});
示例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();
});
}));
});
示例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();
});
}));
});
示例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/);
});
}));
});