redoc/lib/components/SideMenu/side-menu.spec.ts

74 lines
1.8 KiB
TypeScript
Raw Normal View History

2015-12-21 22:39:40 +03:00
'use strict';
2016-06-12 20:44:34 +03:00
import { getChildDebugElement } from '../../../tests/helpers';
2016-05-09 22:55:16 +03:00
import { Component, provide } from '@angular/core';
2016-06-12 20:44:34 +03:00
import { OptionsService } from '../../services/index';
2015-12-21 22:39:40 +03:00
import {
2016-04-30 00:45:53 +03:00
inject,
async,
2015-12-21 22:39:40 +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-21 22:39:40 +03:00
2016-06-12 20:44:34 +03:00
import { MethodsList, SideMenu } from '../index';
2016-05-09 22:55:16 +03:00
2016-06-22 21:17:48 +03:00
import { SpecManager } from '../../utils/SpecManager';;
2015-12-21 22:39:40 +03:00
2016-06-12 20:44:34 +03:00
let testOptions;
2016-05-09 22:55:16 +03:00
2015-12-21 22:39:40 +03:00
describe('Redoc components', () => {
describe('SideMenu Component', () => {
let builder;
let component;
let fixture;
beforeEachProviders(() => [
2016-06-22 21:17:48 +03:00
provide(SpecManager, {useValue: new SpecManager()})
2015-12-21 22:39:40 +03:00
]);
2016-06-22 21:17:48 +03:00
beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService],
2016-06-12 20:44:34 +03:00
(tcb, schemaMgr, opts) => {
2015-12-21 22:39:40 +03:00
builder = tcb;
2016-06-12 20:44:34 +03:00
testOptions = opts;
testOptions.options = {
scrollYOffset: () => 0,
scrollParent: window
};
2016-04-30 00:45:53 +03:00
return schemaMgr.load('/tests/schemas/extended-petstore.yml');
})));
2015-12-21 22:39:40 +03:00
2016-05-09 22:55:16 +03:00
beforeEach((done) => {
2016-06-13 20:54:24 +03:00
builder.createAsync(TestAppComponent).then(_fixture => {
2016-05-09 22:55:16 +03:00
fixture = _fixture;
component = getChildDebugElement(fixture.debugElement, 'side-menu').componentInstance;
fixture.detectChanges();
done();
}, err => {
throw err;
2015-12-22 18:02:03 +03:00
});
2015-12-21 22:39:40 +03:00
});
2016-05-09 22:55:16 +03:00
afterEach(() => {
if (fixture) fixture.destroy();
});
2015-12-22 18:02:03 +03:00
2016-05-09 22:55:16 +03:00
it('should init component and component data', () => {
expect(component).not.toBeNull();
expect(component.data).not.toBeNull();
2015-12-21 22:39:40 +03:00
});
});
});
/** Test component that contains an ApiInfo. */
@Component({
selector: 'test-app',
2015-12-21 22:39:40 +03:00
directives: [MethodsList, SideMenu],
template:
`<side-menu></side-menu>
<methods-list></methods-list>`
})
2016-06-13 20:54:24 +03:00
class TestAppComponent {
2015-12-21 22:39:40 +03:00
}