mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-05 12:30:34 +03:00
refactor tests
This commit is contained in:
parent
bde8f742a4
commit
68286279f7
|
@ -17,6 +17,8 @@ import SchemaManager from 'lib/utils/SchemaManager';
|
|||
|
||||
describe('ApiInfo Component', () => {
|
||||
let builder;
|
||||
let component;
|
||||
let fixture;
|
||||
beforeEachProviders(() => [
|
||||
provide(SchemaManager, {useValue: new SchemaManager()})
|
||||
]);
|
||||
|
@ -24,27 +26,26 @@ describe('ApiInfo Component', () => {
|
|||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/api-info-test.json').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
|
||||
|
||||
it('shold init component data', (done) => {
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
let apiInfoComponent = getChildDebugElement(fixture.debugElement, 'api-info').componentInstance;
|
||||
expect(apiInfoComponent).not.toBeNull();
|
||||
beforeEach((done) => {
|
||||
builder.createAsync(TestApp).then(_fixture => {
|
||||
fixture = _fixture;
|
||||
component = getChildDebugElement(fixture.debugElement, 'api-info').componentInstance;
|
||||
fixture.detectChanges();
|
||||
expect(apiInfoComponent.data).not.toBeNull();
|
||||
apiInfoComponent.data.title.should.be.equal('Swagger Petstore');
|
||||
done();
|
||||
}, err => done.fail(err));
|
||||
});
|
||||
|
||||
it('shold render api name and version', (done) => {
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
let nativeElement = getChildDebugElement(fixture.debugElement, 'api-info').nativeElement;
|
||||
let headerElement = nativeElement.querySelector('h1');
|
||||
fixture.detectChanges();
|
||||
expect(headerElement).toHaveText('Swagger Petstore (1.0.0)');
|
||||
done();
|
||||
}, err => done.fail(err));
|
||||
|
||||
it('shold init component data', () => {
|
||||
expect(component).not.toBeNull();
|
||||
expect(component.data).not.toBeNull();
|
||||
component.data.title.should.be.equal('Swagger Petstore');
|
||||
});
|
||||
|
||||
it('shold render api name and version', () => {
|
||||
let nativeElement = getChildDebugElement(fixture.debugElement, 'api-info').nativeElement;
|
||||
let headerElement = nativeElement.querySelector('h1');
|
||||
expect(headerElement).toHaveText('Swagger Petstore (1.0.0)');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ import Method from 'lib/components/Method/method';
|
|||
import SchemaManager from 'lib/utils/SchemaManager';
|
||||
|
||||
|
||||
describe('jjj Component', () => {
|
||||
describe('Method Component', () => {
|
||||
let builder;
|
||||
let component;
|
||||
beforeEachProviders(() => [
|
||||
provide(SchemaManager, {useValue: new SchemaManager()})
|
||||
]);
|
||||
|
@ -24,31 +25,33 @@ describe('jjj Component', () => {
|
|||
builder = tcb;
|
||||
return schemaMgr.load('/tests/schemas/extended-petstore.json').then(() => null, (err) => { throw err; });
|
||||
}));
|
||||
|
||||
|
||||
it('should init component', (done) => {
|
||||
beforeEach((done) => {
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
let component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
|
||||
expect(component).not.toBeNull();
|
||||
component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
}, err => done.fail(err));
|
||||
});
|
||||
|
||||
it('should init basic component data', (done) => {
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
let component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
|
||||
fixture.detectChanges();
|
||||
|
||||
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}');
|
||||
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 an Method. */
|
||||
/** Test component that contains a Method. */
|
||||
@Component({selector: 'test-app'})
|
||||
@View({
|
||||
directives: [Method],
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('Redoc Component', () => {
|
|||
});
|
||||
|
||||
|
||||
/** Test component that contains an Redoc. */
|
||||
/** Test component that contains a Redoc. */
|
||||
@Component({selector: 'test-app'})
|
||||
@View({
|
||||
directives: [Redoc],
|
||||
|
|
Loading…
Reference in New Issue
Block a user