fix tests

This commit is contained in:
Roman Hotsiy 2016-07-10 16:05:28 +03:00
parent 186ce7ab6f
commit 17dc1c46df
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 6 additions and 3 deletions

View File

@ -23,11 +23,15 @@ describe('Redoc components', () => {
fixture = builder.createSync(TestAppComponent);
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
component = <JsonSchemaLazy>debugEl.componentInstance;
spyOn(component, '_loadAfterSelf').and.stub();
spyOn(component, '_loadAfterSelf').and.callThrough();
spyOn(component.resolver, 'resolveComponent').and.returnValue({ then: () => {
return { catch: () => {/**/} };
}});
});
afterEach(() => {
component._loadAfterSelf.and.callThrough();
component.resolver.resolveComponent.and.callThrough();
});
it('should init component', () => {

View File

@ -34,7 +34,7 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
}
_loadAfterSelf() {
// FIXME: get rid of DynamicComponentLoader as it is deprecated
this.loaded = true;
return this.resolver.resolveComponent(JsonSchema).then(componentFactory => {
let contextInjector = this.location.parentInjector;
let compRef = this.location.createComponent(
@ -42,7 +42,6 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
this.initComponent(compRef.instance);
this._renderer.setElementAttribute(compRef.location.nativeElement, 'class', this.location.element.nativeElement.className);
compRef.changeDetectorRef.detectChanges();
this.loaded = true;
return compRef;
}).catch(err => {
console.log(err);