2015-12-21 00:34:20 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-12 20:44:34 +03:00
|
|
|
import { getChildDebugElement } from '../../../tests/helpers';
|
2016-07-01 15:53:16 +03:00
|
|
|
import { Component } from '@angular/core';
|
2015-12-21 00:34:20 +03:00
|
|
|
|
|
|
|
import {
|
2016-04-30 00:45:53 +03:00
|
|
|
inject,
|
2016-05-06 00:48:41 +03:00
|
|
|
async,
|
2016-09-02 23:18:31 +03:00
|
|
|
TestBed
|
2016-05-06 00:48:41 +03:00
|
|
|
} from '@angular/core/testing';
|
|
|
|
|
2016-06-12 20:44:34 +03:00
|
|
|
import { ApiLogo } from './api-logo';
|
2016-10-23 20:18:42 +03:00
|
|
|
import { SpecManager } from '../../utils/spec-manager';
|
2015-12-21 00:34:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
describe('Redoc components', () => {
|
|
|
|
describe('ApiLogo Component', () => {
|
|
|
|
let builder;
|
|
|
|
let component;
|
|
|
|
let fixture;
|
2016-06-23 17:36:38 +03:00
|
|
|
let specMgr;
|
2015-12-21 00:34:20 +03:00
|
|
|
|
|
|
|
let schemaUrl = '/tests/schemas/api-info-test.json';
|
2016-09-02 23:18:31 +03:00
|
|
|
beforeEach(() => {
|
|
|
|
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
|
|
|
|
});
|
2016-11-24 16:29:29 +03:00
|
|
|
|
2016-09-02 23:18:31 +03:00
|
|
|
beforeEach(async(inject([SpecManager], ( _specMgr) => {
|
2016-06-23 17:36:38 +03:00
|
|
|
specMgr = _specMgr;
|
2016-04-30 00:45:53 +03:00
|
|
|
})));
|
2016-11-24 16:29:29 +03:00
|
|
|
|
|
|
|
beforeEach(done => {
|
|
|
|
specMgr.load(schemaUrl).then(done, done.fail);
|
|
|
|
});
|
|
|
|
|
2016-07-01 15:53:16 +03:00
|
|
|
beforeEach(() => {
|
2016-09-02 23:18:31 +03:00
|
|
|
fixture = TestBed.createComponent(TestAppComponent);
|
2016-07-01 15:53:16 +03:00
|
|
|
component = getChildDebugElement(fixture.debugElement, 'api-logo').componentInstance;
|
|
|
|
fixture.detectChanges();
|
2015-12-21 00:34:20 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should init component data', () => {
|
2016-11-24 16:29:29 +03:00
|
|
|
if (specMgr.a) return;
|
2015-12-21 00:34:20 +03:00
|
|
|
expect(component).not.toBeNull();
|
2016-07-20 11:07:08 +03:00
|
|
|
expect(component.logo).not.toBeNull();
|
2015-12-21 00:34:20 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should not display image when no x-logo', () => {
|
2016-07-20 11:07:08 +03:00
|
|
|
component.logo.should.be.empty();
|
2015-12-21 00:34:20 +03:00
|
|
|
let nativeElement = getChildDebugElement(fixture.debugElement, 'api-logo').nativeElement;
|
|
|
|
let imgElement = nativeElement.querySelector('img');
|
|
|
|
expect(imgElement).toBeNull();
|
|
|
|
|
|
|
|
// update schemaUrl to load other schema in the next test
|
2016-02-01 15:47:21 +03:00
|
|
|
schemaUrl = '/tests/schemas/extended-petstore.yml';
|
2015-12-21 00:34:20 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should load values from spec and use transparent bgColor by default', () => {
|
2016-07-20 11:07:08 +03:00
|
|
|
component.logo.imgUrl.should.endWith('petstore-logo.png');
|
|
|
|
component.logo.bgColor.should.be.equal('transparent');
|
2015-12-21 00:34:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/** Test component that contains an ApiInfo. */
|
2016-03-27 18:25:46 +03:00
|
|
|
@Component({
|
|
|
|
selector: 'test-app',
|
2015-12-21 00:34:20 +03:00
|
|
|
template:
|
|
|
|
`<api-logo></api-logo>`
|
|
|
|
})
|
2016-06-13 20:54:24 +03:00
|
|
|
class TestAppComponent {
|
2015-12-21 00:34:20 +03:00
|
|
|
}
|