mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 05:53:03 +00:00
Merge branch 'main' into w2p-87382_circular-dependency-fixes
This commit is contained in:
@@ -8,12 +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 { 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';
|
||||
import { FindListOptions } from '../../core/data/find-list-options.model';
|
||||
|
||||
describe('SearchFormComponent', () => {
|
||||
@@ -35,7 +34,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,29 +48,23 @@ describe('SearchFormComponent', () => {
|
||||
el = de.nativeElement;
|
||||
});
|
||||
|
||||
it('should display scopes when available with default and all scopes', () => {
|
||||
it('should not display scopes when showScopeSelector is false', fakeAsync(() => {
|
||||
comp.showScopeSelector = false;
|
||||
|
||||
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('');
|
||||
tick();
|
||||
|
||||
let index = 1;
|
||||
objects.forEach((object) => {
|
||||
expect(options.item(index).textContent).toBe(object.name);
|
||||
expect(options.item(index).getAttribute('value')).toBe(object.uuid);
|
||||
index++;
|
||||
});
|
||||
});
|
||||
expect(de.query(By.css('.scope-button'))).toBeFalsy();
|
||||
}));
|
||||
|
||||
it('should display scopes when showScopeSelector is true', fakeAsync(() => {
|
||||
comp.showScopeSelector = true;
|
||||
|
||||
it('should not display scopes when empty', () => {
|
||||
fixture.detectChanges();
|
||||
const select = de.query(By.css('select'));
|
||||
expect(select).toBeNull();
|
||||
});
|
||||
tick();
|
||||
|
||||
expect(de.query(By.css('.scope-button'))).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should display set query value in input field', fakeAsync(() => {
|
||||
const testString = 'This is a test query';
|
||||
@@ -84,17 +78,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'
|
||||
@@ -118,7 +112,7 @@ describe('SearchFormComponent', () => {
|
||||
//
|
||||
// expect(comp.updateSearch).toHaveBeenCalledWith({ scope: scope, query: query });
|
||||
// }));
|
||||
});
|
||||
});
|
||||
|
||||
export const objects: DSpaceObject[] = [
|
||||
Object.assign(new Community(), {
|
||||
|
Reference in New Issue
Block a user