2015-12-12 23:13:26 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-10-23 20:18:42 +03:00
|
|
|
import { SpecManager } from '../utils/spec-manager';
|
2016-06-12 20:44:34 +03:00
|
|
|
import { BaseComponent } from '../components/base';
|
2017-04-19 12:41:15 +03:00
|
|
|
import { OptionsService } from '../services/options.service';
|
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(() => {
|
2017-04-19 12:41:15 +03:00
|
|
|
specMgr = new SpecManager(new OptionsService());
|
2016-06-23 17:36:38 +03:00
|
|
|
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
|
|
|
});
|