本文整理匯總了TypeScript中angular2/test.TestComponentBuilder類的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestComponentBuilder類的具體用法?TypeScript TestComponentBuilder怎麽用?TypeScript TestComponentBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TestComponentBuilder類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: inject
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, '<div><about></about></div>')
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
var aboutInstance = rootTC.componentViewChildren[0].componentInstance;
var aboutDOMEl = rootTC.componentViewChildren[0].nativeElement;
var nameListLen = function () {
return aboutInstance.list.names.length;
}
expect(aboutInstance.list).toEqual(jasmine.any(NamesList));
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');
async.done();
});
}));
示例2: inject
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, '<div><home></home></div>')
.createAsync(TestComponent)
.then((rootTC) => {
var homeDOMEl = rootTC.componentViewChildren[0].nativeElement;
expect(DOM.querySelectorAll(homeDOMEl, 'h1')[0].textContent).toEqual('Howdy!');
async.done();
});
}));
示例3: describe
describe('Login[component]', () => {
let builder: TestComponentBuilder;
beforeEach(inject([TestComponentBuilder], (tcb) => { builder = tcb; }));
it('should have login visible by default', inject([AsyncTestCompleter], (async) => {
builder.createAsync(TestApp)
.then((rootTC) => {
var Login = rootTC.componentViewChildren[0].componentInstance;
expect(Login.hideLogin).toEqual(false);
async.done();
})
.catch((e) => {
console.error(e);
async.done();
})
}));
});
示例4: it
it('should have login visible by default', inject([AsyncTestCompleter], (async) => {
builder.createAsync(TestApp)
.then((rootTC) => {
var Login = rootTC.componentViewChildren[0].componentInstance;
expect(Login.hideLogin).toEqual(false);
async.done();
})
.catch((e) => {
console.error(e);
async.done();
})
}));