redoc/lib/components/base.spec.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

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', () => {
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());
specMgr._schema = {tags: []};
2015-12-12 23:13:26 +03:00
});
2015-12-19 20:36:28 +03:00
beforeEach(() => {
component = new BaseComponent(specMgr);
2015-12-12 23:13:26 +03:00
});
2015-12-19 20:36:28 +03:00
it('should set instance properties', () => {
component.specMgr.should.be.equal(specMgr);
//component.schema.should.be.of.type('object');
2015-12-19 20:36:28 +03:00
expect(component.componentSchema).toBeNull();
});
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();
component.componentSchema.should.be.deepEqual(specMgr._schema.tags);
2015-12-14 11:18:46 +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
});