mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-27 16:14:08 +03:00
Updated tests after angular update
This commit is contained in:
parent
9d13b702b3
commit
e8716ab69d
|
@ -46,6 +46,8 @@ module.exports = function (config) {
|
|||
//load angular dependencies and browser polyfills
|
||||
files: [
|
||||
'node_modules/zone.js/dist/zone.js',
|
||||
'node_modules/zone.js/dist/fake-async-test.js',
|
||||
'node_modules/zone.js/dist/async-test.js',
|
||||
'node_modules/zone.js/dist/jasmine-patch.js',
|
||||
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||
'node_modules/babel-polyfill/dist/polyfill.js',
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('Common components', () => {
|
|||
builder.createAsync(TestApp).then(_fixture => {
|
||||
fixture = _fixture;
|
||||
let debugEl = getChildDebugElementByType(fixture.debugElement, StickySidebar);
|
||||
component = debugEl.componentInstance;
|
||||
component = debugEl.injector.get(StickySidebar);
|
||||
done();
|
||||
}, err => done.fail(err));
|
||||
});
|
||||
|
|
|
@ -5,7 +5,8 @@ import {Component, provide} from 'angular2/core';
|
|||
|
||||
import {
|
||||
TestComponentBuilder,
|
||||
injectAsync,
|
||||
async,
|
||||
inject,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
it
|
||||
|
@ -26,10 +27,12 @@ describe('Redoc components', () => {
|
|||
provide(SchemaManager, {useValue: new SchemaManager()}),
|
||||
provide(OptionsManager, {useValue: optsMgr})
|
||||
]);
|
||||
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
|
||||
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/api-info-test.json').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
return schemaMgr.load('/tests/schemas/api-info-test.json');
|
||||
})));
|
||||
|
||||
beforeEach((done) => {
|
||||
builder.createAsync(TestApp).then(_fixture => {
|
||||
fixture = _fixture;
|
||||
|
|
|
@ -5,7 +5,8 @@ import {Component, provide} from 'angular2/core';
|
|||
|
||||
import {
|
||||
TestComponentBuilder,
|
||||
injectAsync,
|
||||
async,
|
||||
inject,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
it
|
||||
|
@ -26,11 +27,11 @@ describe('Redoc components', () => {
|
|||
beforeEachProviders(() => [
|
||||
provide(SchemaManager, {useValue: new SchemaManager()})
|
||||
]);
|
||||
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, _schemaMgr) => {
|
||||
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, _schemaMgr) => {
|
||||
builder = tcb;
|
||||
schemaMgr = _schemaMgr;
|
||||
return schemaMgr.load(schemaUrl).then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
return schemaMgr.load(schemaUrl);
|
||||
})));
|
||||
beforeEach((done) => {
|
||||
builder.createAsync(TestApp).then(_fixture => {
|
||||
fixture = _fixture;
|
||||
|
|
|
@ -6,7 +6,8 @@ import {BrowserDomAdapter} from 'angular2/platform/browser';
|
|||
|
||||
import {
|
||||
TestComponentBuilder,
|
||||
injectAsync,
|
||||
async,
|
||||
inject,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
it
|
||||
|
@ -25,10 +26,10 @@ describe('Redoc components', () => {
|
|||
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
|
||||
provide(OptionsManager, {useClass: OptionsManager})
|
||||
]);
|
||||
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/extended-petstore.yml').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
return schemaMgr.load('/tests/schemas/extended-petstore.yml');
|
||||
})));
|
||||
beforeEach((done) => {
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
|
||||
|
|
|
@ -7,7 +7,8 @@ import {BrowserDomAdapter} from 'angular2/platform/browser';
|
|||
|
||||
import {
|
||||
TestComponentBuilder,
|
||||
injectAsync,
|
||||
inject,
|
||||
async,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
it
|
||||
|
@ -26,10 +27,10 @@ describe('Redoc components', () => {
|
|||
provide(OptionsManager, {useClass: OptionsManager}),
|
||||
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter})
|
||||
]);
|
||||
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/methods-list-component.json').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
return schemaMgr.load('/tests/schemas/methods-list-component.json');
|
||||
})));
|
||||
beforeEach((done) => {
|
||||
builder.createAsync(TestApp).then(_fixture => {
|
||||
fixture = _fixture;
|
||||
|
|
|
@ -66,7 +66,7 @@ export default class Redoc extends BaseComponent {
|
|||
];
|
||||
|
||||
if (Redoc.appRef) {
|
||||
Redoc.dispose();
|
||||
Redoc.destroy();
|
||||
}
|
||||
Redoc.showLoadingAnimation();
|
||||
return SchemaManager.instance().load(specUrl)
|
||||
|
@ -102,7 +102,7 @@ export default class Redoc extends BaseComponent {
|
|||
}
|
||||
}
|
||||
|
||||
static dispose() {
|
||||
static destroy() {
|
||||
let el = dom.query('redoc');
|
||||
let elClone;
|
||||
let parent;
|
||||
|
@ -115,10 +115,10 @@ export default class Redoc extends BaseComponent {
|
|||
elClone = el.cloneNode(false);
|
||||
|
||||
if (Redoc.appRef) {
|
||||
Redoc.appRef.dispose();
|
||||
Redoc.appRef.destroy();
|
||||
Redoc.appRef = null;
|
||||
|
||||
// Redoc dispose removes host element, so need to restore it
|
||||
// Redoc destroy removes host element, so need to restore it
|
||||
elClone.innerHTML = 'Loading...';
|
||||
parent && parent.insertBefore(elClone, nextSibling);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ import {BrowserDomAdapter} from 'angular2/platform/browser';
|
|||
|
||||
import {
|
||||
TestComponentBuilder,
|
||||
injectAsync,
|
||||
inject,
|
||||
async,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
it
|
||||
|
@ -26,10 +27,10 @@ describe('Redoc components', () => {
|
|||
provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}),
|
||||
provide(OptionsManager, {useValue: optsMgr})
|
||||
]);
|
||||
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/extended-petstore.yml').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
return schemaMgr.load('/tests/schemas/extended-petstore.yml');
|
||||
})));
|
||||
|
||||
|
||||
it('should init component', (done) => {
|
||||
|
@ -141,29 +142,29 @@ describe('Redoc components', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Redoc dispose', () => {
|
||||
describe('Redoc destroy', () => {
|
||||
let builder;
|
||||
let fixture;
|
||||
let element;
|
||||
let disposeSpy;
|
||||
let destroySpy;
|
||||
let dom = new BrowserDomAdapter();
|
||||
beforeEachProviders(() => [
|
||||
provide(SchemaManager, {useValue: new SchemaManager()}),
|
||||
provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}),
|
||||
provide(OptionsManager, {useValue: optsMgr})
|
||||
]);
|
||||
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/methods-list-component.json').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
return schemaMgr.load('/tests/schemas/methods-list-component.json');
|
||||
})));
|
||||
|
||||
beforeEach((done) => {
|
||||
builder.createAsync(TestApp).then(_fixture => {
|
||||
fixture = _fixture;
|
||||
element = getChildDebugElement(fixture.debugElement, 'methods-list').nativeElement;
|
||||
disposeSpy = jasmine.createSpy('spy');
|
||||
destroySpy = jasmine.createSpy('spy');
|
||||
Redoc.appRef = {
|
||||
dispose: disposeSpy
|
||||
destroy: destroySpy
|
||||
};
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
|
@ -175,20 +176,20 @@ describe('Redoc components', () => {
|
|||
Redoc.appRef = null;
|
||||
});
|
||||
|
||||
it('should call componentRef.dispose', () => {
|
||||
Redoc.dispose();
|
||||
expect(disposeSpy).toHaveBeenCalled();
|
||||
it('should call componentRef.destroy', () => {
|
||||
Redoc.destroy();
|
||||
expect(destroySpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should create new host element', () => {
|
||||
element.parentElement.removeChild(element);
|
||||
Redoc.dispose();
|
||||
Redoc.destroy();
|
||||
expect(dom.query('redoc')).not.toBeNull();
|
||||
dom.query('redoc').should.not.be.equal(element);
|
||||
});
|
||||
|
||||
it('should set to null appRef', () => {
|
||||
Redoc.dispose();
|
||||
Redoc.destroy();
|
||||
expect(Redoc.appRef).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,8 @@ import OptionsManager from 'lib/options';
|
|||
|
||||
import {
|
||||
TestComponentBuilder,
|
||||
injectAsync,
|
||||
inject,
|
||||
async,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
it
|
||||
|
@ -34,10 +35,10 @@ describe('Redoc components', () => {
|
|||
provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}),
|
||||
provide(OptionsManager, {useValue: testOptions})
|
||||
]);
|
||||
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
||||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/extended-petstore.yml').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
return schemaMgr.load('/tests/schemas/extended-petstore.yml');
|
||||
})));
|
||||
|
||||
afterEach(() => {
|
||||
if (fixture) fixture.destroy();
|
||||
|
|
|
@ -105,6 +105,6 @@
|
|||
"sinon": "^1.17.2",
|
||||
"systemjs-builder": "^0.15.2",
|
||||
"vinyl-paths": "^2.0.0",
|
||||
"zone.js": "^0.6.6"
|
||||
"zone.js": "^0.6.12"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user