diff --git a/lib/components/JsonSchema/json-schema-lazy.spec.ts b/lib/components/JsonSchema/json-schema-lazy.spec.ts index f6cb50cb..d1026189 100644 --- a/lib/components/JsonSchema/json-schema-lazy.spec.ts +++ b/lib/components/JsonSchema/json-schema-lazy.spec.ts @@ -2,7 +2,6 @@ import { getChildDebugElement } from '../../../tests/helpers'; import { Component, provide } from '@angular/core'; -import { DynamicComponentLoader } from '@angular/core'; import { inject, @@ -23,34 +22,22 @@ describe('Redoc components', () => { let component; let specMgr = new SpecManager(); let fixture; - let loader; - let appRefMock = { - instance: { - pointer: '' - }, - hostView: { changeDetectorRef: {detectChanges : () => undefined} } - }; beforeEachProviders(() => [ provide(SpecManager, {useValue: specMgr}) ]); - beforeEach(inject([TestComponentBuilder, DynamicComponentLoader], (tcb, dcl) => { + beforeEach(inject([TestComponentBuilder], (tcb, dcl) => { builder = tcb; - loader = dcl; - spyOn(loader, 'loadNextToLocation').and.returnValue({then: (fn) => fn(appRefMock)}); })); beforeEach((done) => { builder.createAsync(TestAppComponent).then(_fixture => { fixture = _fixture; let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy'); component = debugEl.componentInstance; + spyOn(component, '_loadAfterSelf').and.callThrough(); done(); }, err => done.fail(err)); }); - afterEach(() => { - loader.loadNextToLocation.and.callThrough(); - }); - it('should init component', () => { expect(component).not.toBeNull(); }); @@ -59,7 +46,7 @@ describe('Redoc components', () => { component.pointer = '#/def'; fixture.detectChanges(); component.load(); - expect(loader.loadNextToLocation).toHaveBeenCalled(); + expect(component._loadAfterSelf).toHaveBeenCalled(); }); it('should not run loadNextToLocation if already loaded', () => { @@ -67,14 +54,7 @@ describe('Redoc components', () => { fixture.detectChanges(); component.load(); component.load(); - expect(loader.loadNextToLocation.calls.count()).toEqual(1); - }); - - it('should init json-schema with correct pointer', () => { - component.pointer = '#/def'; - fixture.detectChanges(); - component.load(); - expect(appRefMock.instance.pointer).toEqual(component.pointer); + expect(component._loadAfterSelf.calls.count()).toEqual(1); }); }); });