mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-30 04:23:44 +03:00
fix tests
This commit is contained in:
parent
1aee332a90
commit
b8a96e25fe
|
@ -51,7 +51,7 @@ export class BaseComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BaseSearchableComponent extends BaseComponent {
|
export abstract class BaseSearchableComponent extends BaseComponent implements OnDestroy {
|
||||||
searchSubscription: Subscription;
|
searchSubscription: Subscription;
|
||||||
constructor(public specMgr: SpecManager, public app: AppStateService) {
|
constructor(public specMgr: SpecManager, public app: AppStateService) {
|
||||||
super(specMgr);
|
super(specMgr);
|
||||||
|
@ -71,14 +71,14 @@ export class BaseSearchableComponent extends BaseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
if (this.searchSubscription) {
|
||||||
this.searchSubscription.unsubscribe();
|
this.searchSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+ Used to destroy component
|
+ Used to destroy component
|
||||||
* @abstract
|
* @abstract
|
||||||
*/
|
*/
|
||||||
ensureSearchIsShown(ptr: string) {
|
abstract ensureSearchIsShown(ptr: string);
|
||||||
// empy
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ export class Marker {
|
||||||
} else {
|
} else {
|
||||||
for (let i=0; i < Math.min(diff, ROLL_LEN); i++) {
|
for (let i=0; i < Math.min(diff, ROLL_LEN); i++) {
|
||||||
let oldInst = this.rolledInstances.shift();
|
let oldInst = this.rolledInstances.shift();
|
||||||
oldInst && oldInst.unmark();
|
if (oldInst) oldInst.unmark();
|
||||||
|
|
||||||
let idx = newIdx + Math.floor(ROLL_LEN/2) - i;
|
let idx = newIdx + Math.floor(ROLL_LEN/2) - i;
|
||||||
let newMark = this.newMarkerAtMenuItem(idx);
|
let newMark = this.newMarkerAtMenuItem(idx);
|
||||||
|
@ -84,7 +84,4 @@ export class Marker {
|
||||||
this.term = null;
|
this.term = null;
|
||||||
this.remark();
|
this.remark();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMark() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ const index = lunr(function () {
|
||||||
this.field('title', {boost: 1.5});
|
this.field('title', {boost: 1.5});
|
||||||
this.field('body');
|
this.field('body');
|
||||||
this.ref('pointer');
|
this.ref('pointer');
|
||||||
})
|
});
|
||||||
|
|
||||||
const store:StringMap<IndexElement> = {};
|
const store:StringMap<IndexElement> = {};
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ export class SearchService {
|
||||||
}
|
}
|
||||||
|
|
||||||
indexPaths(swagger:any) {
|
indexPaths(swagger:any) {
|
||||||
const paths = swagger.paths
|
const paths = swagger.paths;
|
||||||
const basePtr = '#/paths';
|
const basePtr = '#/paths';
|
||||||
Object.keys(paths).forEach(path => {
|
Object.keys(paths).forEach(path => {
|
||||||
let opearations = paths[path];
|
let opearations = paths[path];
|
||||||
|
@ -74,7 +74,7 @@ export class SearchService {
|
||||||
body: operation.description
|
body: operation.description
|
||||||
});
|
});
|
||||||
this.indexOperationResponses(operation, operationPointer);
|
this.indexOperationResponses(operation, operationPointer);
|
||||||
this.indexOperationParameters(operation, operationPointer)
|
this.indexOperationParameters(operation, operationPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
indexOperationParameters(operation: any, operationPointer: string) {
|
indexOperationParameters(operation: any, operationPointer: string) {
|
||||||
|
@ -143,13 +143,13 @@ export class SearchService {
|
||||||
menuId: menuPointer,
|
menuId: menuPointer,
|
||||||
title,
|
title,
|
||||||
body
|
body
|
||||||
})
|
});
|
||||||
|
|
||||||
if (schema.properties) {
|
if (schema.properties) {
|
||||||
Object.keys(schema.properties).forEach(propName => {
|
Object.keys(schema.properties).forEach(propName => {
|
||||||
let propPtr = JsonPointer.join(absolutePointer, ['properties', propName]);
|
let propPtr = JsonPointer.join(absolutePointer, ['properties', propName]);
|
||||||
this.indexSchema(schema.properties[propName], propName, propPtr, menuPointer);
|
this.indexSchema(schema.properties[propName], propName, propPtr, menuPointer);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('Common components', () => {
|
||||||
});
|
});
|
||||||
describe('Zippy Component', () => {
|
describe('Zippy Component', () => {
|
||||||
let builder;
|
let builder;
|
||||||
let component;
|
let component: Zippy;
|
||||||
let nativeElement;
|
let nativeElement;
|
||||||
let fixture;
|
let fixture;
|
||||||
|
|
||||||
|
@ -33,13 +33,13 @@ describe('Common components', () => {
|
||||||
|
|
||||||
it('should init component defaults', () => {
|
it('should init component defaults', () => {
|
||||||
component.empty.should.be.false();
|
component.empty.should.be.false();
|
||||||
component.visible.should.be.false();
|
component.open.should.be.false();
|
||||||
component.type.should.be.equal('general');
|
component.type.should.be.equal('general');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init properties from dom params', () => {
|
it('should init properties from dom params', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.visible.should.be.true();
|
component.open.should.be.true();
|
||||||
component.empty.should.be.true();
|
component.empty.should.be.true();
|
||||||
component.title.should.be.equal('Zippy');
|
component.title.should.be.equal('Zippy');
|
||||||
component.type.should.be.equal('test');
|
component.type.should.be.equal('test');
|
||||||
|
@ -54,7 +54,7 @@ describe('Common components', () => {
|
||||||
it('should open and close zippy', (done) => {
|
it('should open and close zippy', (done) => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.empty = false;
|
component.empty = false;
|
||||||
component.visible = true;
|
component.open = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
let testComponent = fixture.debugElement.componentInstance;
|
let testComponent = fixture.debugElement.componentInstance;
|
||||||
|
@ -62,13 +62,13 @@ describe('Common components', () => {
|
||||||
let titleEl = nativeElement.querySelector('.zippy-title');
|
let titleEl = nativeElement.querySelector('.zippy-title');
|
||||||
mouseclick(titleEl);
|
mouseclick(titleEl);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.visible.should.be.false();
|
component.open.should.be.false();
|
||||||
testComponent.opened.should.be.false();
|
testComponent.opened.should.be.false();
|
||||||
|
|
||||||
mouseclick(titleEl);
|
mouseclick(titleEl);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
component.visible.should.be.true();
|
component.open.should.be.true();
|
||||||
testComponent.opened.should.be.true();
|
testComponent.opened.should.be.true();
|
||||||
testComponent.clickCount.should.be.equal(2);
|
testComponent.clickCount.should.be.equal(2);
|
||||||
done();
|
done();
|
||||||
|
@ -95,21 +95,17 @@ describe('Common components', () => {
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'test-app',
|
selector: 'test-app',
|
||||||
template:
|
template:
|
||||||
`<zippy title="Zippy" type="test" [visible]="true" [empty]="true" (open)="open()" (close)="close()">test</zippy>`
|
`<zippy title="Zippy" type="test" [open]="true" [empty]="true" (openChange)="open($event)">test</zippy>`
|
||||||
})
|
})
|
||||||
class TestApp {
|
class TestApp {
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
clickCount: number;
|
clickCount: number;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
this.clickCount = 0;
|
this.clickCount = -1; // initial change detection
|
||||||
}
|
}
|
||||||
open() {
|
open(val) {
|
||||||
this.opened = true;
|
this.opened = val;
|
||||||
this.clickCount++;
|
|
||||||
}
|
|
||||||
close() {
|
|
||||||
this.opened = false;
|
|
||||||
this.clickCount++;
|
this.clickCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ export interface DescendantInfo {
|
||||||
$ref: string;
|
$ref: string;
|
||||||
name: string;
|
name: string;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
idx: number;
|
idx?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SpecManager {
|
export class SpecManager {
|
||||||
|
@ -208,7 +208,7 @@ export class SpecManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.push({name: derivedName, $ref: `#/definitions/${defName}`, idx: null});
|
res.push({name: derivedName, $ref: `#/definitions/${defName}`});
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ beforeEach(function() {
|
||||||
services.OptionsService,
|
services.OptionsService,
|
||||||
services.ComponentParser,
|
services.ComponentParser,
|
||||||
services.ContentProjector,
|
services.ContentProjector,
|
||||||
|
services.Marker,
|
||||||
|
services.SearchService,
|
||||||
{ provide: sharedComponents.LazyTasksService, useClass: sharedComponents.LazyTasksServiceSync },
|
{ provide: sharedComponents.LazyTasksService, useClass: sharedComponents.LazyTasksServiceSync },
|
||||||
{ provide: ErrorHandler, useClass: services.CustomErrorHandler },
|
{ provide: ErrorHandler, useClass: services.CustomErrorHandler },
|
||||||
{ provide: services.COMPONENT_PARSER_ALLOWED, useValue: { 'security-definitions': components.SecurityDefinitions }}
|
{ provide: services.COMPONENT_PARSER_ALLOWED, useValue: { 'security-definitions': components.SecurityDefinitions }}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user