mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
55693: ItemSelectComponent tests intermediate + ItemSelectServiceStub
This commit is contained in:
37
src/app/shared/testing/item-select-service-stub.ts
Normal file
37
src/app/shared/testing/item-select-service-stub.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
export class ItemSelectServiceStub {
|
||||
|
||||
ids: string[] = [];
|
||||
|
||||
constructor(ids?: string[]) {
|
||||
if (ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
}
|
||||
|
||||
getSelected(id: string): Observable<boolean> {
|
||||
if (this.ids.indexOf(id) > -1) {
|
||||
return Observable.of(true);
|
||||
} else {
|
||||
return Observable.of(false);
|
||||
}
|
||||
}
|
||||
|
||||
getAllSelected(): Observable<string[]> {
|
||||
return Observable.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 = [];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user