2015-12-18 11:36:01 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import { getChildDebugElement } from 'tests/helpers';
|
2016-05-09 22:55:16 +03:00
|
|
|
import { Component, provide } from '@angular/core';
|
2015-12-18 11:36:01 +03:00
|
|
|
|
|
|
|
import {
|
2016-04-30 00:45:53 +03:00
|
|
|
inject,
|
2016-05-06 00:48:41 +03:00
|
|
|
async,
|
2015-12-18 11:36:01 +03:00
|
|
|
beforeEach,
|
|
|
|
beforeEachProviders,
|
|
|
|
it
|
2016-05-06 00:48:41 +03:00
|
|
|
} from '@angular/core/testing';
|
|
|
|
|
|
|
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
2015-12-18 11:36:01 +03:00
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
import { ApiInfo } from 'lib/components/ApiInfo/api-info';
|
2015-12-18 11:36:01 +03:00
|
|
|
import SchemaManager from 'lib/utils/SchemaManager';
|
2016-05-06 12:46:41 +03:00
|
|
|
import { OptionsService } from 'lib/services/index';
|
2015-12-18 11:36:01 +03:00
|
|
|
|
2016-05-06 12:46:41 +03:00
|
|
|
let optionsService = new OptionsService();
|
2015-12-18 11:36:01 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
describe('Redoc components', () => {
|
|
|
|
describe('ApiInfo Component', () => {
|
|
|
|
let builder;
|
|
|
|
let component;
|
|
|
|
let fixture;
|
|
|
|
beforeEachProviders(() => [
|
2016-03-31 01:15:54 +03:00
|
|
|
provide(SchemaManager, {useValue: new SchemaManager()}),
|
2016-05-06 12:46:41 +03:00
|
|
|
provide(OptionsService, {useValue: optionsService})
|
2015-12-19 20:36:28 +03:00
|
|
|
]);
|
2016-04-30 00:45:53 +03:00
|
|
|
|
|
|
|
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
|
2015-12-19 20:36:28 +03:00
|
|
|
builder = tcb;
|
2016-04-30 00:45:53 +03:00
|
|
|
return schemaMgr.load('/tests/schemas/api-info-test.json');
|
|
|
|
})));
|
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
beforeEach((done) => {
|
|
|
|
builder.createAsync(TestApp).then(_fixture => {
|
|
|
|
fixture = _fixture;
|
|
|
|
component = getChildDebugElement(fixture.debugElement, 'api-info').componentInstance;
|
|
|
|
fixture.detectChanges();
|
|
|
|
done();
|
2016-05-09 22:55:16 +03:00
|
|
|
}, err => {
|
|
|
|
done.fail(err);
|
|
|
|
});
|
2015-12-19 20:36:28 +03:00
|
|
|
});
|
2015-12-18 11:36:01 +03:00
|
|
|
|
2015-12-19 14:36:05 +03:00
|
|
|
|
2016-01-20 16:50:11 +03:00
|
|
|
it('should init component data', () => {
|
2015-12-19 20:36:28 +03:00
|
|
|
expect(component).not.toBeNull();
|
|
|
|
expect(component.data).not.toBeNull();
|
|
|
|
component.data.title.should.be.equal('Swagger Petstore');
|
|
|
|
});
|
2015-12-19 14:36:05 +03:00
|
|
|
|
2016-01-20 16:50:11 +03:00
|
|
|
it('should render api name and version', () => {
|
2015-12-19 20:36:28 +03:00
|
|
|
let nativeElement = getChildDebugElement(fixture.debugElement, 'api-info').nativeElement;
|
|
|
|
let headerElement = nativeElement.querySelector('h1');
|
|
|
|
expect(headerElement).toHaveText('Swagger Petstore (1.0.0)');
|
|
|
|
});
|
2015-12-18 11:36:01 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-12-19 03:26:42 +03:00
|
|
|
/** Test component that contains an ApiInfo. */
|
2016-03-27 18:25:46 +03:00
|
|
|
@Component({
|
|
|
|
selector: 'test-app',
|
2015-12-18 11:36:01 +03:00
|
|
|
directives: [ApiInfo],
|
|
|
|
template:
|
|
|
|
`<api-info></api-info>`
|
|
|
|
})
|
|
|
|
class TestApp {
|
|
|
|
}
|