本文整理汇总了TypeScript中angular2/src/test_lib/test_bed.TestBed类的典型用法代码示例。如果您正苦于以下问题:TypeScript TestBed类的具体用法?TypeScript TestBed怎么用?TypeScript TestBed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestBed类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: inject
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html =
'<div>' +
'<copy-me template="ng-if numberCondition + 1 >= 2">helloNumber</copy-me>' +
'<copy-me template="ng-if stringCondition == \'foo\'">helloString</copy-me>' +
'<copy-me template="ng-if functionCondition(stringCondition, numberCondition)">helloFunction</copy-me>' +
'</div>';
tb.createView(TestComponent, {html: html})
.then((view) => {
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(3);
expect(DOM.getText(view.rootNodes[0]))
.toEqual('helloNumberhelloStringhelloFunction');
view.context.numberCondition = 0;
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.rootNodes[0])).toEqual('helloString');
view.context.numberCondition = 1;
view.context.stringCondition = "bar";
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.rootNodes[0])).toEqual('helloNumber');
async.done();
});
}));
开发者ID:AsherBarak,项目名称:angular,代码行数:28,代码来源:ng_if_spec.ts
示例2: inject
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<ul><li template="ng-for #item of items">{{item["name"]}};</li></ul>';
tb.createView(TestComponent, {html: template})
.then((view) => {
// INIT
view.context.items = [{'name': 'misko'}, {'name': 'shyam'}];
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('misko;shyam;');
// GROW
ListWrapper.push(view.context.items, {'name': 'adam'});
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('misko;shyam;adam;');
// SHRINK
ListWrapper.removeAt(view.context.items, 2);
ListWrapper.removeAt(view.context.items, 0);
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('shyam;');
async.done();
});
}));
开发者ID:B-Thapa,项目名称:angular,代码行数:26,代码来源:ng_for_spec.ts
示例3: inject
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>' +
'<ul [ng-switch]="switchValue">' +
'<template [ng-switch-when]="\'a\'"><li>when a1;</li></template>' +
'<template [ng-switch-when]="\'b\'"><li>when b1;</li></template>' +
'<template [ng-switch-when]="\'a\'"><li>when a2;</li></template>' +
'<template [ng-switch-when]="\'b\'"><li>when b2;</li></template>' +
'<template ng-switch-default><li>when default1;</li></template>' +
'<template ng-switch-default><li>when default2;</li></template>' +
'</ul></div>';
tb.createView(TestComponent, {html: template})
.then((view) => {
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('when default1;when default2;');
view.context.switchValue = 'a';
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('when a1;when a2;');
view.context.switchValue = 'b';
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('when b1;when b2;');
async.done();
});
}));
开发者ID:Salim-K,项目名称:angular,代码行数:27,代码来源:ng_switch_spec.ts
示例4: inject
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>{{text}}<span ng-non-bindable>{{text}}</span></div>';
tb.createView(TestComponent, {html: template})
.then((view) => {
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('foo{{text}}');
async.done();
});
}));
开发者ID:AsherBarak,项目名称:angular,代码行数:9,代码来源:non_bindable_spec.ts
注:本文中的angular2/src/test_lib/test_bed.TestBed类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论