Files
dspace-angular/src/app/shared/testing/object-select-service-stub.ts
2018-11-23 17:03:35 +01:00

39 lines
663 B
TypeScript

import { Observable } from 'rxjs';
import { of } from 'rxjs/internal/observable/of';
export class ObjectSelectServiceStub {
ids: string[] = [];
constructor(ids?: string[]) {
if (ids) {
this.ids = ids;
}
}
getSelected(id: string): Observable<boolean> {
if (this.ids.indexOf(id) > -1) {
return of(true);
} else {
return of(false);
}
}
getAllSelected(): Observable<string[]> {
return of(this.ids);
}
switch(id: string) {
const index = this.ids.indexOf(id);
if (index > -1) {
this.ids.splice(index, 1);
} else {
this.ids.push(id);
}
}
reset() {
this.ids = [];
}
}