refactor(core): update forward_ref_integration_spec not to use TestComponentBuilder
This commit is contained in:
parent
f12d51992d
commit
75405ae0f5
|
@ -6,38 +6,43 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {NgFor} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {Component, ContentChildren, Directive, Inject, QueryList, asNativeElements, forwardRef} from '@angular/core';
|
import {Component, ContentChildren, Directive, Inject, NgModule, QueryList, asNativeElements, forwardRef} from '@angular/core';
|
||||||
import {AsyncTestCompleter, TestComponentBuilder, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('forwardRef integration', function() {
|
describe('forwardRef integration', function() {
|
||||||
it('should instantiate components which are declared using forwardRef',
|
beforeEach(() => { TestBed.configureTestingModule({imports: [Module], declarations: [App]}); });
|
||||||
inject(
|
|
||||||
[TestComponentBuilder, AsyncTestCompleter],
|
it('should instantiate components which are declared using forwardRef', () => {
|
||||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
const a = TestBed.createComponent(App);
|
||||||
tcb.createAsync(App).then((tc) => {
|
a.detectChanges();
|
||||||
tc.detectChanges();
|
expect(asNativeElements(a.debugElement.children)).toHaveText('frame(lock)');
|
||||||
expect(asNativeElements(tc.debugElement.children)).toHaveText('frame(lock)');
|
expect(TestBed.get(ModuleFrame)).toBeDefined();
|
||||||
async.done();
|
});
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [CommonModule],
|
||||||
|
providers: [forwardRef(() => ModuleFrame)],
|
||||||
|
declarations: [forwardRef(() => Door), forwardRef(() => Lock)],
|
||||||
|
exports: [forwardRef(() => Door), forwardRef(() => Lock)]
|
||||||
|
})
|
||||||
|
class Module {
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app',
|
selector: 'app',
|
||||||
viewProviders: [forwardRef(() => Frame)],
|
viewProviders: [forwardRef(() => Frame)],
|
||||||
template: `<door><lock></lock></door>`,
|
template: `<door><lock></lock></door>`,
|
||||||
directives: [forwardRef(() => Door), forwardRef(() => Lock)],
|
|
||||||
})
|
})
|
||||||
class App {
|
class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'lock',
|
selector: 'lock',
|
||||||
directives: [NgFor],
|
|
||||||
template: `{{frame.name}}(<span *ngFor="let lock of locks">{{lock.name}}</span>)`,
|
template: `{{frame.name}}(<span *ngFor="let lock of locks">{{lock.name}}</span>)`,
|
||||||
})
|
})
|
||||||
class Door {
|
class Door {
|
||||||
|
@ -51,6 +56,10 @@ class Frame {
|
||||||
name: string = 'frame';
|
name: string = 'frame';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ModuleFrame {
|
||||||
|
name: string = 'moduleFram';
|
||||||
|
}
|
||||||
|
|
||||||
@Directive({selector: 'lock'})
|
@Directive({selector: 'lock'})
|
||||||
class Lock {
|
class Lock {
|
||||||
name: string = 'lock';
|
name: string = 'lock';
|
||||||
|
|
Loading…
Reference in New Issue