mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
62372: Post-merge test fixes
This commit is contained in:
@@ -29,7 +29,9 @@ describe('MyDSpaceConfigurationService', () => {
|
||||
|
||||
const spy = jasmine.createSpyObj('RouteService', {
|
||||
getQueryParameterValue: observableOf(value1),
|
||||
getQueryParamsWithPrefix: observableOf(prefixFilter)
|
||||
getQueryParamsWithPrefix: observableOf(prefixFilter),
|
||||
getRouteParameterValue: observableOf(''),
|
||||
getRouteDataValue: observableOf({})
|
||||
});
|
||||
|
||||
const activatedRoute: any = new ActivatedRouteStub();
|
||||
|
@@ -28,6 +28,7 @@ import { SearchFilterService } from '../+search-page/search-filters/search-filte
|
||||
import { RoleDirective } from '../shared/roles/role.directive';
|
||||
import { RoleService } from '../core/roles/role.service';
|
||||
import { MockRoleService } from '../shared/mocks/mock-role-service';
|
||||
import { SearchFixedFilterService } from '../+search-page/search-filters/search-filter/search-fixed-filter.service';
|
||||
|
||||
describe('MyDSpacePageComponent', () => {
|
||||
let comp: MyDSpacePageComponent;
|
||||
@@ -79,6 +80,11 @@ describe('MyDSpacePageComponent', () => {
|
||||
collapse: () => this.isCollapsed = observableOf(true),
|
||||
expand: () => this.isCollapsed = observableOf(false)
|
||||
};
|
||||
const mockFixedFilterService: SearchFixedFilterService = {
|
||||
getQueryByFilterName: (filter: string) => {
|
||||
return observableOf(undefined)
|
||||
}
|
||||
} as SearchFixedFilterService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -117,6 +123,10 @@ describe('MyDSpacePageComponent', () => {
|
||||
{
|
||||
provide: RoleService,
|
||||
useValue: new MockRoleService()
|
||||
},
|
||||
{
|
||||
provide: SearchFixedFilterService,
|
||||
useValue: mockFixedFilterService
|
||||
}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
|
@@ -24,6 +24,7 @@ import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.compone
|
||||
import { RouteService } from '../shared/services/route.service';
|
||||
import { SearchConfigurationServiceStub } from '../shared/testing/search-configuration-service-stub';
|
||||
import { PaginatedSearchOptions } from './paginated-search-options.model';
|
||||
import { SearchFixedFilterService } from './search-filters/search-filter/search-fixed-filter.service';
|
||||
|
||||
let comp: SearchPageComponent;
|
||||
let fixture: ComponentFixture<SearchPageComponent>;
|
||||
@@ -79,8 +80,19 @@ const sidebarService = {
|
||||
const routeServiceStub = {
|
||||
getRouteParameterValue: () => {
|
||||
return observableOf('');
|
||||
},
|
||||
getQueryParameterValue: () => {
|
||||
return observableOf('')
|
||||
},
|
||||
getQueryParamsWithPrefix: () => {
|
||||
return observableOf('')
|
||||
}
|
||||
};
|
||||
const mockFixedFilterService: SearchFixedFilterService = {
|
||||
getQueryByFilterName: (filter: string) => {
|
||||
return observableOf(undefined)
|
||||
}
|
||||
} as SearchFixedFilterService;
|
||||
|
||||
export function configureSearchComponentTestingModule(compType) {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -113,6 +125,10 @@ export function configureSearchComponentTestingModule(compType) {
|
||||
provide: SearchFilterService,
|
||||
useValue: {}
|
||||
},
|
||||
{
|
||||
provide: SearchFixedFilterService,
|
||||
useValue: mockFixedFilterService
|
||||
},
|
||||
{
|
||||
provide: SearchConfigurationService,
|
||||
useValue: {
|
||||
|
@@ -22,7 +22,7 @@ export class TypedItemSearchResultListElementComponent extends SearchResultListE
|
||||
@Inject(ITEM) public obj: Item | ItemSearchResult,
|
||||
) {
|
||||
super(undefined, truncatableService);
|
||||
if (hasValue((obj as any).dspaceObject)) {
|
||||
if (hasValue((obj as any).indexableObject)) {
|
||||
this.object = obj as ItemSearchResult;
|
||||
this.dso = this.object.indexableObject;
|
||||
} else {
|
||||
|
@@ -8,6 +8,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
let itemSearchResultListElementComponent: ItemSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
|
||||
@@ -16,29 +17,25 @@ const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithAuthorAndDate.hitHighlights = {};
|
||||
mockItemWithAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
||||
const type = 'authorOfPublication';
|
||||
|
||||
const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithRelationshipType.hitHighlights = {};
|
||||
mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.contributor.author': [
|
||||
'relationship.type': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
}
|
||||
],
|
||||
'dc.date.issued': [
|
||||
{
|
||||
language: null,
|
||||
value: '2015-06-26'
|
||||
value: type
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutAuthorAndDate.hitHighlights = {};
|
||||
mockItemWithoutAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
||||
const mockItemWithoutRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutRelationshipType.hitHighlights = {};
|
||||
mockItemWithoutRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -46,12 +43,6 @@ mockItemWithoutAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'dc.type': [
|
||||
{
|
||||
language: null,
|
||||
value: 'Article'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
@@ -59,11 +50,11 @@ mockItemWithoutAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
||||
describe('ItemSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule],
|
||||
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
{ provide: 'objectElementProvider', useValue: (mockItemWithoutAuthorAndDate) }
|
||||
{ provide: 'objectElementProvider', useValue: (mockItemWithoutRelationshipType) }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemSearchResultListElementComponent, {
|
||||
@@ -76,51 +67,28 @@ describe('ItemSearchResultListElementComponent', () => {
|
||||
itemSearchResultListElementComponent = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe('When the item has an author', () => {
|
||||
describe('When the item has a relationship type', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithAuthorAndDate.indexableObject;
|
||||
itemSearchResultListElementComponent.object = mockItemWithRelationshipType;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
it('should show the relationship type badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('span.badge'));
|
||||
console.log(itemSearchResultListElementComponent.dso);
|
||||
expect(badge.nativeElement.textContent).toContain(type.toLowerCase());
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no author', () => {
|
||||
describe('When the item has no relationship type', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithoutAuthorAndDate.indexableObject;
|
||||
itemSearchResultListElementComponent.object = mockItemWithoutRelationshipType;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has an issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithAuthorAndDate.indexableObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the issuedate span', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithoutAuthorAndDate.indexableObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the issuedate span', () => {
|
||||
const dateField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(dateField).toBeNull();
|
||||
it('should not show a badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('span.badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -21,6 +21,12 @@ export const routeServiceStub: any = {
|
||||
},
|
||||
getQueryParameterValue: () => {
|
||||
return observableOf({})
|
||||
},
|
||||
getRouteParameterValue: (param) => {
|
||||
return observableOf('')
|
||||
},
|
||||
getRouteDataValue: (param) => {
|
||||
return observableOf({})
|
||||
}
|
||||
/* tslint:enable:no-empty */
|
||||
};
|
||||
|
Reference in New Issue
Block a user