mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fixed existing tests
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { ExistingMetadataListElementComponent } from './existing-metadata-list-element.component';
|
import { ExistingMetadataListElementComponent } from './existing-metadata-list-element.component';
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { SelectableListService } from '../../../../object-list/selectable-list/selectable-list.service';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
describe('ExistingMetadataListElementComponent', () => {
|
describe('ExistingMetadataListElementComponent', () => {
|
||||||
let component: ExistingMetadataListElementComponent;
|
let component: ExistingMetadataListElementComponent;
|
||||||
@@ -8,7 +11,12 @@ describe('ExistingMetadataListElementComponent', () => {
|
|||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [ ExistingMetadataListElementComponent ]
|
declarations: [ExistingMetadataListElementComponent],
|
||||||
|
providers: [
|
||||||
|
{ provide: SelectableListService, useValue: {} },
|
||||||
|
{ provide: Store, useValue: {} },
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
@@ -15,11 +15,13 @@ import { Store } from '@ngrx/store';
|
|||||||
import { AppState } from '../../../../../app.reducer';
|
import { AppState } from '../../../../../app.reducer';
|
||||||
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
||||||
|
|
||||||
|
// tslint:disable:max-classes-per-file
|
||||||
export abstract class Reorderable {
|
export abstract class Reorderable {
|
||||||
constructor(public oldIndex?: number, public newIndex?: number) {
|
constructor(public oldIndex?: number, public newIndex?: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract getId(): string;
|
abstract getId(): string;
|
||||||
|
|
||||||
abstract getPlace(): number;
|
abstract getPlace(): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,3 +109,4 @@ export class ExistingMetadataListElementComponent implements OnChanges, OnDestro
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// tslint:enable:max-classes-per-file
|
||||||
|
@@ -16,7 +16,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of } from 'rxjs/internal/observable/of';
|
import { of } from 'rxjs/internal/observable/of';
|
||||||
|
|
||||||
fdescribe('ItemSelectComponent', () => {
|
describe('ItemSelectComponent', () => {
|
||||||
let comp: ItemSelectComponent;
|
let comp: ItemSelectComponent;
|
||||||
let fixture: ComponentFixture<ItemSelectComponent>;
|
let fixture: ComponentFixture<ItemSelectComponent>;
|
||||||
let objectSelectService: ObjectSelectService;
|
let objectSelectService: ObjectSelectService;
|
||||||
|
@@ -1,8 +1,28 @@
|
|||||||
import { ChangeDetectorRef, Component, EventEmitter, HostListener, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
import {
|
||||||
|
ChangeDetectorRef,
|
||||||
|
Component,
|
||||||
|
EventEmitter,
|
||||||
|
HostListener,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
OnInit,
|
||||||
|
Output,
|
||||||
|
SimpleChanges
|
||||||
|
} from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
|
|
||||||
import { BehaviorSubject, combineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
||||||
import { debounceTime, distinctUntilChanged, filter, map, mergeMap, reduce, startWith, flatMap, find } from 'rxjs/operators';
|
import {
|
||||||
|
debounceTime,
|
||||||
|
distinctUntilChanged,
|
||||||
|
filter,
|
||||||
|
find,
|
||||||
|
flatMap,
|
||||||
|
map,
|
||||||
|
mergeMap,
|
||||||
|
reduce,
|
||||||
|
startWith
|
||||||
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import { Collection } from '../../../core/shared/collection.model';
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
import { CommunityDataService } from '../../../core/data/community-data.service';
|
import { CommunityDataService } from '../../../core/data/community-data.service';
|
||||||
@@ -197,23 +217,21 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
|
|||||||
find((communities: RemoteData<PaginatedList<Community>>) => isNotEmpty(communities.payload)),
|
find((communities: RemoteData<PaginatedList<Community>>) => isNotEmpty(communities.payload)),
|
||||||
mergeMap((communities: RemoteData<PaginatedList<Community>>) => communities.payload.page));
|
mergeMap((communities: RemoteData<PaginatedList<Community>>) => communities.payload.page));
|
||||||
|
|
||||||
const listCollection$ = observableOf([]);
|
const listCollection$ = communities$.pipe(
|
||||||
|
flatMap((communityData: Community) => {
|
||||||
// const listCollection$ = communities$.pipe(
|
return this.collectionDataService.getAuthorizedCollectionByCommunity(communityData.uuid, findOptions).pipe(
|
||||||
// flatMap((communityData: Community) => {
|
find((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending && collections.hasSucceeded),
|
||||||
// return this.collectionDataService.getAuthorizedCollectionByCommunity(communityData.uuid, findOptions).pipe(
|
mergeMap((collections: RemoteData<PaginatedList<Collection>>) => collections.payload.page),
|
||||||
// find((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending && collections.hasSucceeded),
|
filter((collectionData: Collection) => isNotEmpty(collectionData)),
|
||||||
// mergeMap((collections: RemoteData<PaginatedList<Collection>>) => collections.payload.page),
|
map((collectionData: Collection) => ({
|
||||||
// filter((collectionData: Collection) => isNotEmpty(collectionData)),
|
communities: [{ id: communityData.id, name: communityData.name }],
|
||||||
// map((collectionData: Collection) => ({
|
collection: { id: collectionData.id, name: collectionData.name }
|
||||||
// communities: [{ id: communityData.id, name: communityData.name }],
|
}))
|
||||||
// collection: { id: collectionData.id, name: collectionData.name }
|
);
|
||||||
// }))
|
}),
|
||||||
// );
|
reduce((acc: any, value: any) => [...acc, ...value], []),
|
||||||
// }),
|
startWith([])
|
||||||
// reduce((acc: any, value: any) => [...acc, ...value], []),
|
);
|
||||||
// startWith([])
|
|
||||||
// );
|
|
||||||
|
|
||||||
const searchTerm$ = this.searchField.valueChanges.pipe(
|
const searchTerm$ = this.searchField.valueChanges.pipe(
|
||||||
debounceTime(200),
|
debounceTime(200),
|
||||||
@@ -229,8 +247,7 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
|
|||||||
} else {
|
} else {
|
||||||
return listCollection.filter((v) => v.collection.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1).slice(0, 5);
|
return listCollection.filter((v) => v.collection.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1).slice(0, 5);
|
||||||
}
|
}
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user