mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +03:00
Add MethodsList component test suite
This commit is contained in:
parent
5bc88ebb0f
commit
b29c49e8d0
63
lib/components/MethodsList/methods-list.spec.js
Normal file
63
lib/components/MethodsList/methods-list.spec.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
'use strict';
|
||||
|
||||
import { getChildDebugElement } from 'tests/helpers';
|
||||
import {Component, View, provide} from 'angular2/core';
|
||||
|
||||
import {
|
||||
TestComponentBuilder,
|
||||
injectAsync,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
it
|
||||
} from 'angular2/testing';
|
||||
|
||||
import MethodsList from 'lib/components/MethodsList/methods-list';
|
||||
import SchemaManager from 'lib/utils/SchemaManager';
|
||||
|
||||
|
||||
describe('ApiInfo Component', () => {
|
||||
let builder;
|
||||
let component;
|
||||
let fixture;
|
||||
beforeEachProviders(() => [
|
||||
provide(SchemaManager, {useValue: new SchemaManager()})
|
||||
]);
|
||||
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();
|
||||
}, err => { throw err; });
|
||||
});
|
||||
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/** Test component that contains an ApiInfo. */
|
||||
@Component({selector: 'test-app'})
|
||||
@View({
|
||||
directives: [MethodsList],
|
||||
providers: [SchemaManager],
|
||||
template:
|
||||
`<methods-list></methods-list>`
|
||||
})
|
||||
class TestApp {
|
||||
}
|
28
tests/schemas/methods-list-component.json
Normal file
28
tests/schemas/methods-list-component.json
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
},
|
||||
"host": "petstore.swagger.io",
|
||||
"basePath": "/v2/",
|
||||
"tags": [{
|
||||
"name": "traitTag",
|
||||
"x-traitTag": true,
|
||||
"description": "description1"
|
||||
},{
|
||||
"name": "tag1",
|
||||
"description": "tag1",
|
||||
}],
|
||||
"schemes": ["http"],
|
||||
"paths": {
|
||||
"/pet": {
|
||||
"post": {
|
||||
"tags": ["tag1"],
|
||||
"summary": "tag1"
|
||||
},
|
||||
"put": {
|
||||
"tags": ["tag1", "traitTag"],
|
||||
"summary": "two tags",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user