mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-03 17:35:46 +03:00
Fix LazySchema tests
This commit is contained in:
parent
44e52febc6
commit
7a73ba2ce5
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import { getChildDebugElement } from '../../../tests/helpers';
|
import { getChildDebugElement } from '../../../tests/helpers';
|
||||||
import { Component, provide } from '@angular/core';
|
import { Component, provide } from '@angular/core';
|
||||||
import { DynamicComponentLoader } from '@angular/core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
inject,
|
inject,
|
||||||
|
@ -23,34 +22,22 @@ describe('Redoc components', () => {
|
||||||
let component;
|
let component;
|
||||||
let specMgr = new SpecManager();
|
let specMgr = new SpecManager();
|
||||||
let fixture;
|
let fixture;
|
||||||
let loader;
|
|
||||||
let appRefMock = {
|
|
||||||
instance: {
|
|
||||||
pointer: ''
|
|
||||||
},
|
|
||||||
hostView: { changeDetectorRef: {detectChanges : () => undefined} }
|
|
||||||
};
|
|
||||||
beforeEachProviders(() => [
|
beforeEachProviders(() => [
|
||||||
provide(SpecManager, {useValue: specMgr})
|
provide(SpecManager, {useValue: specMgr})
|
||||||
]);
|
]);
|
||||||
beforeEach(inject([TestComponentBuilder, DynamicComponentLoader], (tcb, dcl) => {
|
beforeEach(inject([TestComponentBuilder], (tcb, dcl) => {
|
||||||
builder = tcb;
|
builder = tcb;
|
||||||
loader = dcl;
|
|
||||||
spyOn(loader, 'loadNextToLocation').and.returnValue({then: (fn) => fn(appRefMock)});
|
|
||||||
}));
|
}));
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
builder.createAsync(TestAppComponent).then(_fixture => {
|
builder.createAsync(TestAppComponent).then(_fixture => {
|
||||||
fixture = _fixture;
|
fixture = _fixture;
|
||||||
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
|
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
|
||||||
component = <JsonSchemaLazy>debugEl.componentInstance;
|
component = <JsonSchemaLazy>debugEl.componentInstance;
|
||||||
|
spyOn(component, '_loadAfterSelf').and.callThrough();
|
||||||
done();
|
done();
|
||||||
}, err => done.fail(err));
|
}, err => done.fail(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
loader.loadNextToLocation.and.callThrough();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should init component', () => {
|
it('should init component', () => {
|
||||||
expect(component).not.toBeNull();
|
expect(component).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
@ -59,7 +46,7 @@ describe('Redoc components', () => {
|
||||||
component.pointer = '#/def';
|
component.pointer = '#/def';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.load();
|
component.load();
|
||||||
expect(loader.loadNextToLocation).toHaveBeenCalled();
|
expect(component._loadAfterSelf).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not run loadNextToLocation if already loaded', () => {
|
it('should not run loadNextToLocation if already loaded', () => {
|
||||||
|
@ -67,14 +54,7 @@ describe('Redoc components', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.load();
|
component.load();
|
||||||
component.load();
|
component.load();
|
||||||
expect(loader.loadNextToLocation.calls.count()).toEqual(1);
|
expect(component._loadAfterSelf.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);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user