2015-12-19 03:24:25 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import { getChildDebugElement } from 'tests/helpers';
|
|
|
|
import {Component, View, provide} from 'angular2/core';
|
|
|
|
|
|
|
|
import {
|
|
|
|
TestComponentBuilder,
|
|
|
|
injectAsync,
|
|
|
|
beforeEach,
|
|
|
|
beforeEachProviders,
|
|
|
|
it
|
|
|
|
} from 'angular2/testing';
|
|
|
|
|
|
|
|
import Method from 'lib/components/Method/method';
|
|
|
|
import SchemaManager from 'lib/utils/SchemaManager';
|
|
|
|
|
|
|
|
|
2015-12-19 14:36:05 +03:00
|
|
|
describe('Method Component', () => {
|
2015-12-19 03:24:25 +03:00
|
|
|
let builder;
|
2015-12-19 14:36:05 +03:00
|
|
|
let component;
|
2015-12-19 03:24:25 +03:00
|
|
|
beforeEachProviders(() => [
|
|
|
|
provide(SchemaManager, {useValue: new SchemaManager()})
|
|
|
|
]);
|
|
|
|
beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
|
|
|
builder = tcb;
|
|
|
|
return schemaMgr.load('/tests/schemas/extended-petstore.json').then(() => null, (err) => { throw err; });
|
|
|
|
}));
|
2015-12-19 14:36:05 +03:00
|
|
|
beforeEach((done) => {
|
2015-12-19 03:24:25 +03:00
|
|
|
builder.createAsync(TestApp).then(fixture => {
|
2015-12-19 14:36:05 +03:00
|
|
|
component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
|
|
|
|
fixture.detectChanges();
|
2015-12-19 03:24:25 +03:00
|
|
|
done();
|
|
|
|
}, err => done.fail(err));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-12-19 14:36:05 +03:00
|
|
|
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;
|
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 {
|
|
|
|
}
|