mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Fixes search passthrough to Mirador and adds tests.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
@@ -17,7 +17,7 @@ import { RemoteData } from '../../../../core/data/remote-data';
|
|||||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||||
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models';
|
||||||
import { UUIDService } from '../../../../core/shared/uuid.service';
|
import { UUIDService } from '../../../../core/shared/uuid.service';
|
||||||
import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock';
|
import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock';
|
||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
@@ -26,22 +26,12 @@ import { TruncatableService } from '../../../../shared/truncatable/truncatable.s
|
|||||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||||
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
||||||
import {
|
import {
|
||||||
createRelationshipsObservable,
|
createRelationshipsObservable, getIIIFEnabled, getIIIFSearchEnabled, mockRouteService
|
||||||
iiifEnabled,
|
|
||||||
iiifSearchEnabled, mockRouteService
|
|
||||||
} from '../shared/item.component.spec';
|
} from '../shared/item.component.spec';
|
||||||
import { PublicationComponent } from './publication.component';
|
import { PublicationComponent } from './publication.component';
|
||||||
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
||||||
import { RouteService } from '../../../../core/services/route.service';
|
import { RouteService } from '../../../../core/services/route.service';
|
||||||
|
import { UntypedItemComponent } from '../untyped-item/untyped-item.component';
|
||||||
const iiifEnabledMap: MetadataMap = {
|
|
||||||
'dspace.iiif.enabled': [iiifEnabled],
|
|
||||||
};
|
|
||||||
|
|
||||||
const iiifEnabledWithSearchMap: MetadataMap = {
|
|
||||||
'dspace.iiif.enabled': [iiifEnabled],
|
|
||||||
'iiif.search.enabled': [iiifSearchEnabled],
|
|
||||||
};
|
|
||||||
|
|
||||||
const noMetadata = new MetadataMap();
|
const noMetadata = new MetadataMap();
|
||||||
|
|
||||||
@@ -72,31 +62,32 @@ describe('PublicationComponent', () => {
|
|||||||
})],
|
})],
|
||||||
declarations: [PublicationComponent, GenericItemPageFieldComponent, TruncatePipe],
|
declarations: [PublicationComponent, GenericItemPageFieldComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: ItemDataService, useValue: {} },
|
{provide: ItemDataService, useValue: {}},
|
||||||
{ provide: TruncatableService, useValue: {} },
|
{provide: TruncatableService, useValue: {}},
|
||||||
{ provide: RelationshipService, useValue: {} },
|
{provide: RelationshipService, useValue: {}},
|
||||||
{ provide: ObjectCacheService, useValue: {} },
|
{provide: ObjectCacheService, useValue: {}},
|
||||||
{ provide: UUIDService, useValue: {} },
|
{provide: UUIDService, useValue: {}},
|
||||||
{ provide: Store, useValue: {} },
|
{provide: Store, useValue: {}},
|
||||||
{ provide: RemoteDataBuildService, useValue: {} },
|
{provide: RemoteDataBuildService, useValue: {}},
|
||||||
{ provide: CommunityDataService, useValue: {} },
|
{provide: CommunityDataService, useValue: {}},
|
||||||
{ provide: HALEndpointService, useValue: {} },
|
{provide: HALEndpointService, useValue: {}},
|
||||||
{ provide: NotificationsService, useValue: {} },
|
{provide: NotificationsService, useValue: {}},
|
||||||
{ provide: HttpClient, useValue: {} },
|
{provide: HttpClient, useValue: {}},
|
||||||
{ provide: DSOChangeAnalyzer, useValue: {} },
|
{provide: DSOChangeAnalyzer, useValue: {}},
|
||||||
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
{provide: DefaultChangeAnalyzer, useValue: {}},
|
||||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
{provide: BitstreamDataService, useValue: mockBitstreamDataService},
|
||||||
{ provide: RouteService, useValue: mockRouteService }
|
{provide: RouteService, useValue: mockRouteService}
|
||||||
],
|
],
|
||||||
|
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(PublicationComponent, {
|
}).overrideComponent(PublicationComponent, {
|
||||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||||
}).compileComponents();
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('default view', () => {
|
describe('default view', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
|
TestBed.compileComponents();
|
||||||
fixture = TestBed.createComponent(PublicationComponent);
|
fixture = TestBed.createComponent(PublicationComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.object = getItem(noMetadata);
|
comp.object = getItem(noMetadata);
|
||||||
@@ -137,6 +128,42 @@ describe('PublicationComponent', () => {
|
|||||||
describe('with IIIF viewer', () => {
|
describe('with IIIF viewer', () => {
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
|
const iiifEnabledMap: MetadataMap = {
|
||||||
|
'dspace.iiif.enabled': [getIIIFEnabled(true)],
|
||||||
|
'iiif.search.enabled': [getIIIFSearchEnabled(false)],
|
||||||
|
};
|
||||||
|
TestBed.compileComponents();
|
||||||
|
fixture = TestBed.createComponent(PublicationComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
comp.object = getItem(iiifEnabledMap);
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should contain an iiif viewer component', () => {
|
||||||
|
const fields = fixture.debugElement.queryAll(By.css('ds-mirador-viewer'));
|
||||||
|
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||||
|
});
|
||||||
|
it('should not retrieve the query term for previous route', fakeAsync((): void => {
|
||||||
|
//tick(10)
|
||||||
|
expect(comp.iiifQuery$).toBeFalsy();
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('with IIIF viewer and search', () => {
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
const localMockRouteService = {
|
||||||
|
getPreviousUrl(): Observable<string> {
|
||||||
|
return of('/search?query=test')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const iiifEnabledMap: MetadataMap = {
|
||||||
|
'dspace.iiif.enabled': [getIIIFEnabled(true)],
|
||||||
|
'iiif.search.enabled': [getIIIFSearchEnabled(true)],
|
||||||
|
};
|
||||||
|
TestBed.overrideProvider(RouteService, {useValue: localMockRouteService});
|
||||||
|
TestBed.compileComponents();
|
||||||
fixture = TestBed.createComponent(PublicationComponent);
|
fixture = TestBed.createComponent(PublicationComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.object = getItem(iiifEnabledMap);
|
comp.object = getItem(iiifEnabledMap);
|
||||||
@@ -148,15 +175,30 @@ describe('PublicationComponent', () => {
|
|||||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should retrieve the query term for previous route', fakeAsync((): void => {
|
||||||
|
//tick(10)
|
||||||
|
expect(comp.iiifQuery$.subscribe(result => expect(result).toEqual('test')));
|
||||||
|
}))
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with IIIF viewer and search', () => {
|
describe('with IIIF viewer and search but no previous search query', () => {
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
mockRouteService.getPreviousUrl.and.returnValue(of(['/search?q=bird&motivation=painting','/item']));
|
const localMockRouteService = {
|
||||||
|
getPreviousUrl(): Observable<string> {
|
||||||
|
return of('/item')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const iiifEnabledMap: MetadataMap = {
|
||||||
|
'dspace.iiif.enabled': [getIIIFEnabled(true)],
|
||||||
|
'iiif.search.enabled': [getIIIFSearchEnabled(true)],
|
||||||
|
};
|
||||||
|
TestBed.overrideProvider(RouteService, {useValue: localMockRouteService});
|
||||||
|
TestBed.compileComponents();
|
||||||
fixture = TestBed.createComponent(PublicationComponent);
|
fixture = TestBed.createComponent(PublicationComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.object = getItem(iiifEnabledWithSearchMap);
|
comp.object = getItem(iiifEnabledMap);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -165,11 +207,12 @@ describe('PublicationComponent', () => {
|
|||||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the RouteService getHistory method', () => {
|
it('should not retrieve the query term for previous route', fakeAsync( () => {
|
||||||
expect(mockRouteService.getPreviousUrl).toHaveBeenCalled();
|
let emitted;
|
||||||
});
|
comp.iiifQuery$.subscribe(result => emitted = result);
|
||||||
|
tick(10)
|
||||||
|
expect(emitted).toBeUndefined();
|
||||||
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { filter, map } from 'rxjs/operators';
|
import { filter, map, take } from 'rxjs/operators';
|
||||||
import { RouteService } from '../../../../core/services/route.service';
|
import { RouteService } from '../../../../core/services/route.service';
|
||||||
|
|
||||||
export const isIiifEnabled = (item: Item) => {
|
export const isIiifEnabled = (item: Item) => {
|
||||||
@@ -26,10 +26,9 @@ export const getDSpaceQuery = (item: Item, routeService: RouteService): Observab
|
|||||||
return r.includes('/search');
|
return r.includes('/search');
|
||||||
}),
|
}),
|
||||||
map(r => {
|
map(r => {
|
||||||
const arr = r.split('&');
|
const v = r.split('query=');
|
||||||
const q = arr[1];
|
|
||||||
const v = q.split('=');
|
|
||||||
return v[1];
|
return v[1];
|
||||||
})
|
}),
|
||||||
|
take(1)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -4,7 +4,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
||||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||||
@@ -33,21 +33,25 @@ import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
|||||||
import { RouteService } from '../../../../core/services/route.service';
|
import { RouteService } from '../../../../core/services/route.service';
|
||||||
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
||||||
|
|
||||||
export const iiifEnabled = Object.assign(new MetadataValue(),{
|
export function getIIIFSearchEnabled(enabled: boolean): MetadataValue {
|
||||||
'value': 'true',
|
return Object.assign(new MetadataValue(), {
|
||||||
|
'value': enabled,
|
||||||
'language': null,
|
'language': null,
|
||||||
'authority': null,
|
'authority': null,
|
||||||
'confidence': -1,
|
'confidence': -1,
|
||||||
'place': 0
|
'place': 0
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const iiifSearchEnabled = Object.assign(new MetadataValue(), {
|
export function getIIIFEnabled(enabled: boolean): MetadataValue {
|
||||||
'value': 'true',
|
return Object.assign(new MetadataValue(), {
|
||||||
|
'value': enabled,
|
||||||
'language': null,
|
'language': null,
|
||||||
'authority': null,
|
'authority': null,
|
||||||
'confidence': -1,
|
'confidence': -1,
|
||||||
'place': 0
|
'place': 0
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const mockRouteService = jasmine.createSpyObj('RouteService', ['getPreviousUrl']);
|
export const mockRouteService = jasmine.createSpyObj('RouteService', ['getPreviousUrl']);
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
||||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||||
@@ -26,13 +26,10 @@ import { TruncatableService } from '../../../../shared/truncatable/truncatable.s
|
|||||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||||
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
||||||
import {
|
import {
|
||||||
createRelationshipsObservable,
|
createRelationshipsObservable, getIIIFEnabled, getIIIFSearchEnabled, mockRouteService
|
||||||
iiifEnabled,
|
|
||||||
iiifSearchEnabled, mockRouteService
|
|
||||||
} from '../shared/item.component.spec';
|
} from '../shared/item.component.spec';
|
||||||
import { UntypedItemComponent } from './untyped-item.component';
|
import { UntypedItemComponent } from './untyped-item.component';
|
||||||
import { RouteService } from '../../../../core/services/route.service';
|
import { RouteService } from '../../../../core/services/route.service';
|
||||||
import { of } from 'rxjs';
|
|
||||||
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
||||||
import { VersionHistoryDataService } from '../../../../core/data/version-history-data.service';
|
import { VersionHistoryDataService } from '../../../../core/data/version-history-data.service';
|
||||||
import { VersionDataService } from '../../../../core/data/version-data.service';
|
import { VersionDataService } from '../../../../core/data/version-data.service';
|
||||||
@@ -41,16 +38,6 @@ import { WorkspaceitemDataService } from '../../../../core/submission/workspacei
|
|||||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||||
import { ItemVersionsSharedService } from '../../../../shared/item/item-versions/item-versions-shared.service';
|
import { ItemVersionsSharedService } from '../../../../shared/item/item-versions/item-versions-shared.service';
|
||||||
|
|
||||||
|
|
||||||
const iiifEnabledMap: MetadataMap = {
|
|
||||||
'dspace.iiif.enabled': [iiifEnabled],
|
|
||||||
};
|
|
||||||
|
|
||||||
const iiifEnabledWithSearchMap: MetadataMap = {
|
|
||||||
'dspace.iiif.enabled': [iiifEnabled],
|
|
||||||
'iiif.search.enabled': [iiifSearchEnabled],
|
|
||||||
};
|
|
||||||
|
|
||||||
const noMetadata = new MetadataMap();
|
const noMetadata = new MetadataMap();
|
||||||
|
|
||||||
function getItem(metadata: MetadataMap) {
|
function getItem(metadata: MetadataMap) {
|
||||||
@@ -108,11 +95,12 @@ describe('UntypedItemComponent', () => {
|
|||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(UntypedItemComponent, {
|
}).overrideComponent(UntypedItemComponent, {
|
||||||
set: {changeDetection: ChangeDetectionStrategy.Default}
|
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||||
}).compileComponents();
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('default view', () => {
|
describe('default view', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
|
TestBed.compileComponents();
|
||||||
fixture = TestBed.createComponent(UntypedItemComponent);
|
fixture = TestBed.createComponent(UntypedItemComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.object = getItem(noMetadata);
|
comp.object = getItem(noMetadata);
|
||||||
@@ -159,6 +147,41 @@ describe('UntypedItemComponent', () => {
|
|||||||
describe('with IIIF viewer', () => {
|
describe('with IIIF viewer', () => {
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
|
const iiifEnabledMap: MetadataMap = {
|
||||||
|
'dspace.iiif.enabled': [getIIIFEnabled(true)],
|
||||||
|
'iiif.search.enabled': [getIIIFSearchEnabled(false)],
|
||||||
|
};
|
||||||
|
TestBed.compileComponents();
|
||||||
|
fixture = TestBed.createComponent(UntypedItemComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
comp.object = getItem(iiifEnabledMap);
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should contain an iiif viewer component', () => {
|
||||||
|
const fields = fixture.debugElement.queryAll(By.css('ds-mirador-viewer'));
|
||||||
|
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||||
|
});
|
||||||
|
it('should not retrieve the query term for previous route', (): void => {
|
||||||
|
expect(comp.iiifQuery$).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('with IIIF viewer and search', () => {
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
const localMockRouteService = {
|
||||||
|
getPreviousUrl(): Observable<string> {
|
||||||
|
return of('/search?query=test')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const iiifEnabledMap: MetadataMap = {
|
||||||
|
'dspace.iiif.enabled': [getIIIFEnabled(true)],
|
||||||
|
'iiif.search.enabled': [getIIIFSearchEnabled(true)],
|
||||||
|
};
|
||||||
|
TestBed.overrideProvider(RouteService, {useValue: localMockRouteService});
|
||||||
|
TestBed.compileComponents();
|
||||||
fixture = TestBed.createComponent(UntypedItemComponent);
|
fixture = TestBed.createComponent(UntypedItemComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.object = getItem(iiifEnabledMap);
|
comp.object = getItem(iiifEnabledMap);
|
||||||
@@ -170,15 +193,29 @@ describe('UntypedItemComponent', () => {
|
|||||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should retrieve the query term for previous route', (): void => {
|
||||||
|
expect(comp.iiifQuery$.subscribe(result => expect(result).toEqual('test')));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with IIIF viewer and search', () => {
|
});
|
||||||
|
|
||||||
|
describe('with IIIF viewer and search but no previous search query', () => {
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
mockRouteService.getPreviousUrl.and.returnValue(of(['/search?q=bird&motivation=painting','/item']));
|
const localMockRouteService = {
|
||||||
|
getPreviousUrl(): Observable<string> {
|
||||||
|
return of('/item')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const iiifEnabledMap: MetadataMap = {
|
||||||
|
'dspace.iiif.enabled': [getIIIFEnabled(true)],
|
||||||
|
'iiif.search.enabled': [getIIIFSearchEnabled(true)],
|
||||||
|
};
|
||||||
|
TestBed.overrideProvider(RouteService, {useValue: localMockRouteService});
|
||||||
|
TestBed.compileComponents();
|
||||||
fixture = TestBed.createComponent(UntypedItemComponent);
|
fixture = TestBed.createComponent(UntypedItemComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.object = getItem(iiifEnabledWithSearchMap);
|
comp.object = getItem(iiifEnabledMap);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -187,9 +224,12 @@ describe('UntypedItemComponent', () => {
|
|||||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the RouteService getHistory method', () => {
|
it('should not retrieve the query term for previous route', fakeAsync( () => {
|
||||||
expect(mockRouteService.getPreviousUrl).toHaveBeenCalled();
|
let emitted;
|
||||||
});
|
comp.iiifQuery$.subscribe(result => emitted = result);
|
||||||
|
tick(10)
|
||||||
|
expect(emitted).toBeUndefined()
|
||||||
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user