mirror of
https://github.com/Redocly/redoc.git
synced 2024-12-25 08:06:20 +03:00
71 lines
2.1 KiB
JavaScript
71 lines
2.1 KiB
JavaScript
'use strict';
|
|
|
|
import { Component, provide } from '@angular/core';
|
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
|
import {
|
|
inject,
|
|
async,
|
|
beforeEach,
|
|
beforeEachProviders,
|
|
it
|
|
} from '@angular/core/testing';
|
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
|
|
|
import { getChildDebugElement } from 'tests/helpers';
|
|
|
|
import { Method } from 'lib/components/Method/method';
|
|
import SchemaManager from 'lib/utils/SchemaManager';
|
|
import { OptionsService, RedocEventsService } from 'lib/services/index';
|
|
|
|
describe('Redoc components', () => {
|
|
describe('Method Component', () => {
|
|
let builder;
|
|
let component;
|
|
beforeEachProviders(() => [
|
|
provide(SchemaManager, {useValue: new SchemaManager()}),
|
|
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
|
|
provide(OptionsService, {useClass: OptionsService}),
|
|
provide(RedocEventsService, {useClass: RedocEventsService})
|
|
]);
|
|
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
|
builder = tcb;
|
|
return schemaMgr.load('/tests/schemas/extended-petstore.yml');
|
|
})));
|
|
beforeEach((done) => {
|
|
builder.createAsync(TestApp).then(fixture => {
|
|
component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
|
|
fixture.detectChanges();
|
|
done();
|
|
}, err => done.fail(err));
|
|
});
|
|
|
|
|
|
it('should init component', () => {
|
|
expect(component).not.toBeNull();
|
|
});
|
|
|
|
it('should init basic component data', () => {
|
|
component.data.apiUrl.should.be.equal('http://petstore.swagger.io/v2');
|
|
component.data.httpMethod.should.be.equal('put');
|
|
component.data.path.should.be.equal('/user/{username}');
|
|
});
|
|
|
|
|
|
it('should main tag', () => {
|
|
component.data.methodInfo.tags.should.be.empty;
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
/** Test component that contains a Method. */
|
|
@Component({
|
|
selector: 'test-app',
|
|
directives: [Method],
|
|
providers: [SchemaManager],
|
|
template:
|
|
`<method pointer='#/paths/~1user~1{username}/put'></method>`
|
|
})
|
|
class TestApp {
|
|
}
|