2015-12-21 22:39:40 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
import { getChildDebugElement } from 'tests/helpers';
|
|
|
|
import { Component, provide } from '@angular/core';
|
|
|
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
|
|
|
import { OptionsService, RedocEventsService } from 'lib/services/index';
|
2015-12-21 22:39:40 +03:00
|
|
|
|
|
|
|
import {
|
2016-04-30 00:45:53 +03:00
|
|
|
inject,
|
|
|
|
async,
|
2015-12-21 22:39:40 +03:00
|
|
|
beforeEach,
|
|
|
|
beforeEachProviders,
|
|
|
|
it
|
2016-05-06 00:48:41 +03:00
|
|
|
} from '@angular/core/testing';
|
|
|
|
|
|
|
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
2015-12-21 22:39:40 +03:00
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
import { MethodsList, SideMenu } from 'lib/components/index';
|
|
|
|
|
2015-12-21 22:39:40 +03:00
|
|
|
import SchemaManager from 'lib/utils/SchemaManager';
|
|
|
|
|
2016-05-06 12:46:41 +03:00
|
|
|
let testOptions = new OptionsService();
|
2016-02-10 18:18:36 +03:00
|
|
|
testOptions.options = {
|
|
|
|
scrollYOffset: () => 0,
|
2015-12-27 00:12:10 +03:00
|
|
|
scrollParent: window
|
2015-12-26 20:44:39 +03:00
|
|
|
};
|
2016-02-10 18:18:36 +03:00
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
let redocEvents = new RedocEventsService();
|
|
|
|
|
2015-12-21 22:39:40 +03:00
|
|
|
describe('Redoc components', () => {
|
|
|
|
describe('SideMenu Component', () => {
|
|
|
|
let builder;
|
|
|
|
let component;
|
|
|
|
let fixture;
|
|
|
|
beforeEachProviders(() => [
|
2015-12-26 20:44:39 +03:00
|
|
|
provide(SchemaManager, {useValue: new SchemaManager()}),
|
|
|
|
provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}),
|
2016-05-09 22:55:16 +03:00
|
|
|
provide(OptionsService, {useValue: testOptions}),
|
|
|
|
provide(RedocEventsService, {useValue: redocEvents})
|
2015-12-21 22:39:40 +03:00
|
|
|
]);
|
2016-04-30 00:45:53 +03:00
|
|
|
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
2015-12-21 22:39:40 +03:00
|
|
|
builder = tcb;
|
2016-04-30 00:45:53 +03:00
|
|
|
return schemaMgr.load('/tests/schemas/extended-petstore.yml');
|
|
|
|
})));
|
2015-12-21 22:39:40 +03:00
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
beforeEach((done) => {
|
|
|
|
builder.createAsync(TestApp).then(_fixture => {
|
|
|
|
fixture = _fixture;
|
|
|
|
component = getChildDebugElement(fixture.debugElement, 'side-menu').componentInstance;
|
|
|
|
fixture.detectChanges();
|
|
|
|
done();
|
|
|
|
}, err => {
|
|
|
|
throw err;
|
2015-12-22 18:02:03 +03:00
|
|
|
});
|
2015-12-21 22:39:40 +03:00
|
|
|
});
|
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
afterEach(() => {
|
|
|
|
if (fixture) fixture.destroy();
|
|
|
|
});
|
2015-12-22 18:02:03 +03:00
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
it('should init component and component data', () => {
|
|
|
|
expect(component).not.toBeNull();
|
|
|
|
expect(component.data).not.toBeNull();
|
2015-12-21 22:39:40 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/** Test component that contains an ApiInfo. */
|
2016-03-27 18:25:46 +03:00
|
|
|
@Component({
|
|
|
|
selector: 'test-app',
|
2015-12-21 22:39:40 +03:00
|
|
|
directives: [MethodsList, SideMenu],
|
|
|
|
template:
|
|
|
|
`<side-menu></side-menu>
|
|
|
|
<methods-list></methods-list>`
|
|
|
|
})
|
|
|
|
class TestApp {
|
|
|
|
}
|