2015-12-19 18:19:18 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import { getChildDebugElement } from 'tests/helpers';
|
2016-03-27 18:25:46 +03:00
|
|
|
import {Component, provide} from 'angular2/core';
|
2016-02-16 16:31:12 +03:00
|
|
|
import OptionsManager from 'lib/options';
|
|
|
|
import {BrowserDomAdapter} from 'angular2/platform/browser';
|
2015-12-19 18:19:18 +03:00
|
|
|
|
|
|
|
import {
|
|
|
|
TestComponentBuilder,
|
|
|
|
injectAsync,
|
|
|
|
beforeEach,
|
|
|
|
beforeEachProviders,
|
|
|
|
it
|
|
|
|
} from 'angular2/testing';
|
|
|
|
|
|
|
|
import MethodsList from 'lib/components/MethodsList/methods-list';
|
|
|
|
import SchemaManager from 'lib/utils/SchemaManager';
|
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
describe('Redoc components', () => {
|
2016-02-16 16:31:12 +03:00
|
|
|
describe('MethodsList Component', () => {
|
2015-12-19 20:36:28 +03:00
|
|
|
let builder;
|
|
|
|
let component;
|
|
|
|
let fixture;
|
|
|
|
beforeEachProviders(() => [
|
2016-02-16 16:31:12 +03:00
|
|
|
provide(SchemaManager, {useValue: new SchemaManager()}),
|
|
|
|
provide(OptionsManager, {useClass: OptionsManager}),
|
|
|
|
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter})
|
2015-12-19 20:36:28 +03:00
|
|
|
]);
|
|
|
|
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
|
|
|
builder = tcb;
|
|
|
|
return schemaMgr.load('/tests/schemas/methods-list-component.json').then(() => null, (err) => { throw err; });
|
|
|
|
}));
|
|
|
|
beforeEach((done) => {
|
|
|
|
builder.createAsync(TestApp).then(_fixture => {
|
|
|
|
fixture = _fixture;
|
|
|
|
component = getChildDebugElement(fixture.debugElement, 'methods-list').componentInstance;
|
|
|
|
fixture.detectChanges();
|
|
|
|
done();
|
2016-02-16 16:31:12 +03:00
|
|
|
}, err => done.fail(err) );
|
2015-12-19 20:36:28 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should init component and component data', () => {
|
|
|
|
expect(component).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should get correct tags list', () => {
|
|
|
|
expect(component.data.tags).not.toBeNull();
|
|
|
|
component.data.tags.should.have.lengthOf(2);
|
|
|
|
component.data.tags[0].name.should.be.equal('traitTag');
|
|
|
|
component.data.tags[0].methods.should.be.empty;
|
|
|
|
component.data.tags[1].name.should.be.equal('tag1');
|
|
|
|
component.data.tags[1].methods.should.have.lengthOf(2);
|
|
|
|
});
|
2015-12-19 18:19:18 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/** Test component that contains an ApiInfo. */
|
2016-03-27 18:25:46 +03:00
|
|
|
@Component({
|
|
|
|
selector: 'test-app',
|
2015-12-19 18:19:18 +03:00
|
|
|
directives: [MethodsList],
|
|
|
|
providers: [SchemaManager],
|
|
|
|
template:
|
|
|
|
`<methods-list></methods-list>`
|
|
|
|
})
|
|
|
|
class TestApp {
|
|
|
|
}
|