fixed existing tests

This commit is contained in:
lotte
2019-12-20 16:48:40 +01:00
parent 4f1dd88923
commit 65b648b000
4 changed files with 53 additions and 25 deletions

View File

@@ -1,6 +1,9 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
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', () => {
let component: ExistingMetadataListElementComponent;
@@ -8,7 +11,12 @@ describe('ExistingMetadataListElementComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ExistingMetadataListElementComponent ]
declarations: [ExistingMetadataListElementComponent],
providers: [
{ provide: SelectableListService, useValue: {} },
{ provide: Store, useValue: {} },
],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));

View File

@@ -15,11 +15,13 @@ import { Store } from '@ngrx/store';
import { AppState } from '../../../../../app.reducer';
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
// tslint:disable:max-classes-per-file
export abstract class Reorderable {
constructor(public oldIndex?: number, public newIndex?: number) {
}
abstract getId(): string;
abstract getPlace(): number;
}
@@ -107,3 +109,4 @@ export class ExistingMetadataListElementComponent implements OnChanges, OnDestro
}
}
// tslint:enable:max-classes-per-file

View File

@@ -16,7 +16,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { of } from 'rxjs/internal/observable/of';
fdescribe('ItemSelectComponent', () => {
describe('ItemSelectComponent', () => {
let comp: ItemSelectComponent;
let fixture: ComponentFixture<ItemSelectComponent>;
let objectSelectService: ObjectSelectService;

View File

@@ -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 { 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 { 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)),
mergeMap((communities: RemoteData<PaginatedList<Community>>) => communities.payload.page));
const listCollection$ = observableOf([]);
// const listCollection$ = communities$.pipe(
// flatMap((communityData: Community) => {
// return this.collectionDataService.getAuthorizedCollectionByCommunity(communityData.uuid, findOptions).pipe(
// find((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending && collections.hasSucceeded),
// mergeMap((collections: RemoteData<PaginatedList<Collection>>) => collections.payload.page),
// filter((collectionData: Collection) => isNotEmpty(collectionData)),
// map((collectionData: Collection) => ({
// communities: [{ id: communityData.id, name: communityData.name }],
// collection: { id: collectionData.id, name: collectionData.name }
// }))
// );
// }),
// reduce((acc: any, value: any) => [...acc, ...value], []),
// startWith([])
// );
const listCollection$ = communities$.pipe(
flatMap((communityData: Community) => {
return this.collectionDataService.getAuthorizedCollectionByCommunity(communityData.uuid, findOptions).pipe(
find((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending && collections.hasSucceeded),
mergeMap((collections: RemoteData<PaginatedList<Collection>>) => collections.payload.page),
filter((collectionData: Collection) => isNotEmpty(collectionData)),
map((collectionData: Collection) => ({
communities: [{ id: communityData.id, name: communityData.name }],
collection: { id: collectionData.id, name: collectionData.name }
}))
);
}),
reduce((acc: any, value: any) => [...acc, ...value], []),
startWith([])
);
const searchTerm$ = this.searchField.valueChanges.pipe(
debounceTime(200),
@@ -229,8 +247,7 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
} else {
return listCollection.filter((v) => v.collection.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1).slice(0, 5);
}
})
);
}));
}
}
}