fix tests

This commit is contained in:
Roman Hotsiy 2017-01-28 15:57:22 +02:00
parent 1aee332a90
commit b8a96e25fe
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
6 changed files with 25 additions and 30 deletions

View File

@ -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;
constructor(public specMgr: SpecManager, public app: AppStateService) {
super(specMgr);
@ -71,14 +71,14 @@ export class BaseSearchableComponent extends BaseComponent {
}
ngOnDestroy() {
this.searchSubscription.unsubscribe();
if (this.searchSubscription) {
this.searchSubscription.unsubscribe();
}
}
/**
+ Used to destroy component
* @abstract
*/
ensureSearchIsShown(ptr: string) {
// empy
}
abstract ensureSearchIsShown(ptr: string);
}

View File

@ -51,7 +51,7 @@ export class Marker {
} else {
for (let i=0; i < Math.min(diff, ROLL_LEN); i++) {
let oldInst = this.rolledInstances.shift();
oldInst && oldInst.unmark();
if (oldInst) oldInst.unmark();
let idx = newIdx + Math.floor(ROLL_LEN/2) - i;
let newMark = this.newMarkerAtMenuItem(idx);
@ -84,7 +84,4 @@ export class Marker {
this.term = null;
this.remark();
}
updateMark() {
}
}

View File

@ -17,7 +17,7 @@ const index = lunr(function () {
this.field('title', {boost: 1.5});
this.field('body');
this.ref('pointer');
})
});
const store:StringMap<IndexElement> = {};
@ -54,7 +54,7 @@ export class SearchService {
}
indexPaths(swagger:any) {
const paths = swagger.paths
const paths = swagger.paths;
const basePtr = '#/paths';
Object.keys(paths).forEach(path => {
let opearations = paths[path];
@ -74,7 +74,7 @@ export class SearchService {
body: operation.description
});
this.indexOperationResponses(operation, operationPointer);
this.indexOperationParameters(operation, operationPointer)
this.indexOperationParameters(operation, operationPointer);
}
indexOperationParameters(operation: any, operationPointer: string) {
@ -143,13 +143,13 @@ export class SearchService {
menuId: menuPointer,
title,
body
})
});
if (schema.properties) {
Object.keys(schema.properties).forEach(propName => {
let propPtr = JsonPointer.join(absolutePointer, ['properties', propName]);
this.indexSchema(schema.properties[propName], propName, propPtr, menuPointer);
})
});
}
}
}

View File

@ -16,7 +16,7 @@ describe('Common components', () => {
});
describe('Zippy Component', () => {
let builder;
let component;
let component: Zippy;
let nativeElement;
let fixture;
@ -33,13 +33,13 @@ describe('Common components', () => {
it('should init component defaults', () => {
component.empty.should.be.false();
component.visible.should.be.false();
component.open.should.be.false();
component.type.should.be.equal('general');
});
it('should init properties from dom params', () => {
fixture.detectChanges();
component.visible.should.be.true();
component.open.should.be.true();
component.empty.should.be.true();
component.title.should.be.equal('Zippy');
component.type.should.be.equal('test');
@ -54,7 +54,7 @@ describe('Common components', () => {
it('should open and close zippy', (done) => {
fixture.detectChanges();
component.empty = false;
component.visible = true;
component.open = true;
fixture.detectChanges();
let testComponent = fixture.debugElement.componentInstance;
@ -62,13 +62,13 @@ describe('Common components', () => {
let titleEl = nativeElement.querySelector('.zippy-title');
mouseclick(titleEl);
fixture.detectChanges();
component.visible.should.be.false();
component.open.should.be.false();
testComponent.opened.should.be.false();
mouseclick(titleEl);
fixture.detectChanges();
setTimeout(() => {
component.visible.should.be.true();
component.open.should.be.true();
testComponent.opened.should.be.true();
testComponent.clickCount.should.be.equal(2);
done();
@ -95,21 +95,17 @@ describe('Common components', () => {
@Component({
selector: 'test-app',
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 {
opened: boolean;
clickCount: number;
constructor() {
this.opened = false;
this.clickCount = 0;
this.clickCount = -1; // initial change detection
}
open() {
this.opened = true;
this.clickCount++;
}
close() {
this.opened = false;
open(val) {
this.opened = val;
this.clickCount++;
}
}

View File

@ -15,7 +15,7 @@ export interface DescendantInfo {
$ref: string;
name: string;
active?: boolean;
idx: number;
idx?: number;
}
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;
}

View File

@ -48,6 +48,8 @@ beforeEach(function() {
services.OptionsService,
services.ComponentParser,
services.ContentProjector,
services.Marker,
services.SearchService,
{ provide: sharedComponents.LazyTasksService, useClass: sharedComponents.LazyTasksServiceSync },
{ provide: ErrorHandler, useClass: services.CustomErrorHandler },
{ provide: services.COMPONENT_PARSER_ALLOWED, useValue: { 'security-definitions': components.SecurityDefinitions }}