redoc/lib/components/Method/method.spec.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-12-19 03:24:25 +03:00
'use strict';
import { getChildDebugElement } from 'tests/helpers';
import {Component, View, provide} from 'angular2/core';
2016-02-10 18:18:36 +03:00
import {BrowserDomAdapter} from 'angular2/platform/browser';
2015-12-19 03:24:25 +03:00
import {
TestComponentBuilder,
injectAsync,
beforeEach,
beforeEachProviders,
it
} from 'angular2/testing';
import Method from 'lib/components/Method/method';
import SchemaManager from 'lib/utils/SchemaManager';
2016-02-10 18:18:36 +03:00
import OptionsManager from 'lib/options';
2015-12-19 03:24:25 +03:00
2015-12-19 20:36:28 +03:00
describe('Redoc components', () => {
describe('Method Component', () => {
let builder;
let component;
beforeEachProviders(() => [
2016-02-10 18:18:36 +03:00
provide(SchemaManager, {useValue: new SchemaManager()}),
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
provide(OptionsManager, {useClass: OptionsManager})
2015-12-19 20:36:28 +03:00
]);
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
builder = tcb;
2016-02-01 15:47:21 +03:00
return schemaMgr.load('/tests/schemas/extended-petstore.yml').then(() => null, (err) => { throw err; });
2015-12-19 20:36:28 +03:00
}));
beforeEach((done) => {
builder.createAsync(TestApp).then(fixture => {
component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
fixture.detectChanges();
done();
}, err => done.fail(err));
});
2015-12-19 03:24:25 +03:00
2015-12-19 20:36:28 +03:00
it('should init component', () => {
expect(component).not.toBeNull();
});
2015-12-19 14:36:05 +03:00
2015-12-19 20:36:28 +03:00
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}');
});
2015-12-19 14:36:05 +03:00
2015-12-19 20:36:28 +03:00
it('should main tag', () => {
component.data.methodInfo.tags.should.be.empty;
});
2015-12-19 03:24:25 +03:00
});
});
2015-12-19 14:36:05 +03:00
/** Test component that contains a Method. */
2015-12-19 03:24:25 +03:00
@Component({selector: 'test-app'})
@View({
directives: [Method],
providers: [SchemaManager],
template:
`<method pointer='#/paths/~1user~1{username}/put'></method>`
})
class TestApp {
}