2015-12-12 23:13:26 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-22 21:17:48 +03:00
|
|
|
import { SpecManager } from '../utils/SpecManager';
|
2016-06-12 20:44:34 +03:00
|
|
|
import { BaseComponent } from '../components/base';
|
2015-12-12 23:13:26 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
describe('Redoc components', () => {
|
|
|
|
describe('BaseComponent', () => {
|
2016-06-23 17:36:38 +03:00
|
|
|
let specMgr;
|
2015-12-19 20:36:28 +03:00
|
|
|
let component;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
2016-06-23 17:36:38 +03:00
|
|
|
specMgr = new SpecManager();
|
|
|
|
specMgr._schema = {tags: []};
|
2015-12-12 23:13:26 +03:00
|
|
|
});
|
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
beforeEach(() => {
|
2016-06-23 17:36:38 +03:00
|
|
|
component = new BaseComponent(specMgr);
|
2015-12-12 23:13:26 +03:00
|
|
|
});
|
2015-12-13 01:04:27 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
it('should set instance properties', () => {
|
2016-06-23 17:36:38 +03:00
|
|
|
component.specMgr.should.be.equal(specMgr);
|
2016-03-27 01:44:11 +03:00
|
|
|
//component.schema.should.be.of.type('object');
|
2015-12-19 20:36:28 +03:00
|
|
|
expect(component.componentSchema).toBeNull();
|
2015-12-13 01:04:27 +03:00
|
|
|
});
|
2015-12-14 11:18:46 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
it('should set componentSchema based on pointer on ngOnInit', () => {
|
|
|
|
component.pointer = '/tags';
|
|
|
|
component.ngOnInit();
|
2016-06-23 17:36:38 +03:00
|
|
|
component.componentSchema.should.be.deepEqual(specMgr._schema.tags);
|
2015-12-14 11:18:46 +03:00
|
|
|
});
|
|
|
|
|
2016-07-20 11:07:08 +03:00
|
|
|
it('should call init virtual methods after init', () => {
|
2016-06-12 20:44:34 +03:00
|
|
|
spyOn(component, 'init');
|
2015-12-19 20:36:28 +03:00
|
|
|
component.ngOnInit();
|
2016-06-12 20:44:34 +03:00
|
|
|
|
|
|
|
component.init.calls.count().should.be.equal(1);
|
|
|
|
component.init.and.callThrough();
|
2015-12-14 11:18:46 +03:00
|
|
|
});
|
|
|
|
});
|
2015-12-12 23:13:26 +03:00
|
|
|
});
|