redoc/lib/components/base.spec.ts

44 lines
1.2 KiB
TypeScript
Raw Normal View History

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', () => {
let schemaMgr;
let component;
beforeAll(() => {
2016-06-22 21:17:48 +03:00
schemaMgr = new SpecManager();
2015-12-19 20:36:28 +03:00
schemaMgr._schema = {tags: []};
2015-12-12 23:13:26 +03:00
});
2015-12-19 20:36:28 +03:00
beforeEach(() => {
component = new BaseComponent(schemaMgr);
2015-12-12 23:13:26 +03:00
});
2015-12-19 20:36:28 +03:00
it('should set instance properties', () => {
component.schemaMgr.should.be.equal(schemaMgr);
//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();
2016-01-09 23:31:39 +03:00
component.componentSchema.should.be.deepEqual(schemaMgr._schema.tags);
2015-12-14 11:18:46 +03:00
});
2015-12-19 20:36:28 +03:00
it('should call prepareModel and init virtual methods after init', () => {
2016-06-12 20:44:34 +03:00
spyOn(component, 'prepareModel');
spyOn(component, 'init');
2015-12-19 20:36:28 +03:00
component.ngOnInit();
2016-06-12 20:44:34 +03:00
component.prepareModel.calls.count().should.be.equal(1);
component.init.calls.count().should.be.equal(1);
component.prepareModel.and.callThrough();
component.init.and.callThrough();
2015-12-14 11:18:46 +03:00
});
});
2015-12-12 23:13:26 +03:00
});