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

60 lines
1.5 KiB
TypeScript
Raw Normal View History

2015-12-19 03:24:25 +03:00
'use strict';
2016-07-01 15:53:16 +03:00
import { Component } from '@angular/core';
2015-12-19 03:24:25 +03:00
import {
2016-04-30 00:45:53 +03:00
inject,
2016-05-06 00:48:41 +03:00
async,
2016-07-01 15:53:16 +03:00
TestComponentBuilder
2016-05-06 00:48:41 +03:00
} from '@angular/core/testing';
2015-12-19 03:24:25 +03:00
2016-06-12 20:44:34 +03:00
import { getChildDebugElement } from '../../../tests/helpers';
2016-05-06 12:46:41 +03:00
2016-06-12 20:44:34 +03:00
import { Method } from './method';
2016-06-22 21:17:48 +03:00
import { SpecManager } from '../../utils/SpecManager';;
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;
2016-07-01 15:53:16 +03:00
beforeEach(async(inject([TestComponentBuilder, SpecManager], (tcb, specMgr) => {
2015-12-19 20:36:28 +03:00
builder = tcb;
return specMgr.load('/tests/schemas/extended-petstore.yml');
2016-04-30 00:45:53 +03:00
})));
2016-07-01 15:53:16 +03:00
beforeEach(() => {
let fixture = builder.createSync(TestAppComponent);
component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
fixture.detectChanges();
2015-12-19 20:36:28 +03:00
});
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', () => {
2016-06-13 20:54:24 +03:00
component.data.methodInfo.tags.should.be.empty();
2015-12-19 20:36:28 +03:00
});
2015-12-19 03:24:25 +03:00
});
});
2015-12-19 14:36:05 +03:00
/** Test component that contains a Method. */
@Component({
selector: 'test-app',
2015-12-19 03:24:25 +03:00
directives: [Method],
2016-06-22 21:17:48 +03:00
providers: [SpecManager],
2015-12-19 03:24:25 +03:00
template:
`<method pointer='#/paths/~1user~1{username}/put'></method>`
})
2016-06-13 20:54:24 +03:00
class TestAppComponent {
2015-12-19 03:24:25 +03:00
}