Merge remote-tracking branch 'upstream/main' into w2p-84367_Various-small-changes

This commit is contained in:
Yura Bondarenko
2022-02-09 16:43:14 +01:00
804 changed files with 50248 additions and 26437 deletions

View File

@@ -8,13 +8,11 @@ import { Community } from '../../core/shared/community.model';
import { TranslateModule } from '@ngx-translate/core';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { SearchService } from '../../core/shared/search/search.service';
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../core/data/request.models';
import { of as observableOf } from 'rxjs';
import { PaginationService } from '../../core/pagination/pagination.service';
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
import { PaginationServiceStub } from '../testing/pagination-service.stub';
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
describe('SearchFormComponent', () => {
let comp: SearchFormComponent;
@@ -35,7 +33,8 @@ describe('SearchFormComponent', () => {
useValue: {}
},
{ provide: PaginationService, useValue: paginationService },
{ provide: SearchConfigurationService, useValue: searchConfigService }
{ provide: SearchConfigurationService, useValue: searchConfigService },
{ provide: DSpaceObjectDataService, useValue: { findById: () => createSuccessfulRemoteDataObject$(undefined)} }
],
declarations: [SearchFormComponent]
}).compileComponents();
@@ -48,24 +47,6 @@ describe('SearchFormComponent', () => {
el = de.nativeElement;
});
it('should display scopes when available with default and all scopes', () => {
comp.scopes = objects;
fixture.detectChanges();
const select: HTMLElement = de.query(By.css('select')).nativeElement;
expect(select).toBeDefined();
const options: HTMLCollection = select.children;
const defOption: Element = options.item(0);
expect(defOption.getAttribute('value')).toBe('');
let index = 1;
objects.forEach((object) => {
expect(options.item(index).textContent).toBe(object.name);
expect(options.item(index).getAttribute('value')).toBe(object.uuid);
index++;
});
});
it('should not display scopes when empty', () => {
fixture.detectChanges();
const select = de.query(By.css('select'));
@@ -94,17 +75,17 @@ describe('SearchFormComponent', () => {
}));
it('should select correct scope option in scope select', fakeAsync(() => {
comp.scopes = objects;
fixture.detectChanges();
fixture.detectChanges();
comp.showScopeSelector = true;
const testCommunity = objects[1];
comp.scope = testCommunity.id;
comp.selectedScope.next(testCommunity);
fixture.detectChanges();
tick();
const scopeSelect = de.query(By.css('select')).nativeElement;
const scopeSelect = de.query(By.css('.scope-button')).nativeElement;
expect(scopeSelect.value).toBe(testCommunity.id);
expect(scopeSelect.textContent).toBe(testCommunity.name);
}));
// it('should call updateSearch when clicking the submit button with correct parameters', fakeAsync(() => {
// comp.query = 'Test String'
@@ -128,7 +109,7 @@ describe('SearchFormComponent', () => {
//
// expect(comp.updateSearch).toHaveBeenCalledWith({ scope: scope, query: query });
// }));
});
});
export const objects: DSpaceObject[] = [
Object.assign(new Community(), {