mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
solved tests
This commit is contained in:
@@ -216,9 +216,9 @@ describe('ItemMetadataComponent', () => {
|
||||
});
|
||||
|
||||
it('it should call reinstateFieldUpdates on the objectUpdatesService with the correct url and metadata', () => {
|
||||
expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.itemRD$.metadataAsList);
|
||||
expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.itemRD$, { metadata: Metadata.toMetadataMap(comp.itemRD$.metadataAsList) }));
|
||||
expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.itemRD$.metadataAsList);
|
||||
expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.item.metadataAsList);
|
||||
expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.item, { metadata: Metadata.toMetadataMap(comp.item.metadataAsList) }));
|
||||
expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.item.metadataAsList);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -117,7 +117,7 @@ describe('EditRelationshipListComponent', () => {
|
||||
fixture = TestBed.createComponent(EditRelationshipListComponent);
|
||||
comp = fixture.componentInstance;
|
||||
de = fixture.debugElement;
|
||||
comp.itemRD$ = item;
|
||||
comp.item = item;
|
||||
comp.url = url;
|
||||
comp.relationshipLabel = relationshipType.leftLabel;
|
||||
fixture.detectChanges();
|
||||
|
@@ -113,7 +113,7 @@ describe('EditRelationshipComponent', () => {
|
||||
|
||||
comp.url = url;
|
||||
comp.fieldUpdate = fieldUpdate1;
|
||||
comp.itemRD$ = item;
|
||||
comp.item = item;
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@@ -156,7 +156,9 @@ describe('ItemRelationshipsComponent', () => {
|
||||
getRelatedItemsByLabel: observableOf([author1, author2]),
|
||||
getItemRelationshipsArray: observableOf(relationships),
|
||||
deleteRelationship: observableOf(new RestResponse(true, 200, 'OK')),
|
||||
getItemResolvedRelatedItemsAndRelationships: observableCombineLatest(observableOf([author1, author2]), observableOf([item, item]), observableOf(relationships))
|
||||
getItemResolvedRelatedItemsAndRelationships: observableCombineLatest(observableOf([author1, author2]), observableOf([item, item]), observableOf(relationships)),
|
||||
getRelationshipsByRelatedItemIds: observableOf(relationships),
|
||||
getRelationshipTypeLabelsByItem: observableOf([relationshipType.leftLabel])
|
||||
}
|
||||
);
|
||||
|
||||
|
@@ -32,7 +32,7 @@ describe('ModifyItemOverviewComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ModifyItemOverviewComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.itemRD$ = mockItem;
|
||||
comp.item = mockItem;
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemPageAbstractFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageAbstractFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.itemRD$ = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -32,7 +32,7 @@ describe('ItemPageAuthorFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageAuthorFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.itemRD$ = mockItemWithMetadataFieldAndValue(field, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(field, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -33,7 +33,7 @@ describe('GenericItemPageFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(GenericItemPageFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.itemRD$ = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.fields = mockFields;
|
||||
comp.label = mockLabel;
|
||||
fixture.detectChanges();
|
||||
|
@@ -40,7 +40,7 @@ describe('ItemPageFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.itemRD$ = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.fields = mockFields;
|
||||
comp.label = mockLabel;
|
||||
fixture.detectChanges();
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemPageTitleFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageTitleFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.itemRD$ = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemPageUriFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageUriFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.itemRD$ = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -29,7 +29,7 @@ describe('RelatedEntitiesSearchComponent', () => {
|
||||
fixture = TestBed.createComponent(RelatedEntitiesSearchComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.relationType = mockRelationType;
|
||||
comp.itemRD$ = mockItem;
|
||||
comp.item = mockItem;
|
||||
comp.relationEntityType = mockRelationEntityType;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@@ -151,6 +151,7 @@ describe('SearchPageComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SearchPageComponent);
|
||||
comp = fixture.componentInstance; // SearchPageComponent test instance
|
||||
comp.inPlaceSearch = false;
|
||||
fixture.detectChanges();
|
||||
searchServiceObject = (comp as any).service;
|
||||
searchConfigurationServiceObject = (comp as any).searchConfigService;
|
||||
|
@@ -132,13 +132,7 @@ import { SearchConfigurationService } from './shared/search/search-configuration
|
||||
import { SelectableListService } from '../shared/object-list/selectable-list/selectable-list.service';
|
||||
import { RelationshipTypeService } from './data/relationship-type.service';
|
||||
|
||||
export const restServiceFactory = (cfg: GlobalConfig, mocks: MockResponseMap, http: HttpClient) => {
|
||||
if (ENV_CONFIG.production) {
|
||||
return new DSpaceRESTv2Service(http);
|
||||
} else {
|
||||
return new EndpointMockingRestService(cfg, mocks, http);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const IMPORTS = [
|
||||
CommonModule,
|
||||
@@ -158,8 +152,7 @@ const PROVIDERS = [
|
||||
CommunityDataService,
|
||||
CollectionDataService,
|
||||
DSOResponseParsingService,
|
||||
{ provide: MOCK_RESPONSE_MAP, useValue: mockResponseMap },
|
||||
{ provide: DSpaceRESTv2Service, useFactory: restServiceFactory, deps: [GLOBAL_CONFIG, MOCK_RESPONSE_MAP, HttpClient]},
|
||||
DSpaceRESTv2Service,
|
||||
DynamicFormLayoutService,
|
||||
DynamicFormService,
|
||||
DynamicFormValidationService,
|
||||
|
@@ -5,7 +5,6 @@ import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-da
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { RequestEntry } from './request.reducer';
|
||||
import { RelationshipType } from '../shared/item-relationships/relationship-type.model';
|
||||
import { ResourceType } from '../shared/resource-type';
|
||||
import { Relationship } from '../shared/item-relationships/relationship.model';
|
||||
import { RemoteData } from './remote-data';
|
||||
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
||||
@@ -15,6 +14,7 @@ import { PageInfo } from '../shared/page-info.model';
|
||||
import { DeleteRequest } from './request.models';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
|
||||
describe('RelationshipService', () => {
|
||||
let service: RelationshipService;
|
||||
@@ -26,7 +26,8 @@ describe('RelationshipService', () => {
|
||||
const rdbService = getMockRemoteDataBuildService();
|
||||
const objectCache = Object.assign({
|
||||
/* tslint:disable:no-empty */
|
||||
remove: () => {}
|
||||
remove: () => {},
|
||||
hasBySelfLinkObservable: () => observableOf(false)
|
||||
/* tslint:enable:no-empty */
|
||||
}) as ObjectCacheService;
|
||||
|
||||
@@ -74,7 +75,8 @@ describe('RelationshipService', () => {
|
||||
const relatedItems = [relatedItem1, relatedItem2];
|
||||
|
||||
const itemService = jasmine.createSpyObj('itemService', {
|
||||
findById: (uuid) => new RemoteData(false, false, true, undefined, relatedItems.filter((relatedItem) => relatedItem.id === uuid)[0])
|
||||
findById: (uuid) => new RemoteData(false, false, true, undefined, relatedItems.find((relatedItem) => relatedItem.id === uuid)),
|
||||
findByHref: createSuccessfulRemoteDataObject$(relatedItems[0])
|
||||
});
|
||||
|
||||
function initTestService() {
|
||||
@@ -131,14 +133,6 @@ describe('RelationshipService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getItemRelationshipLabels', () => {
|
||||
it('should return the correct labels', () => {
|
||||
service.getItemRelationshipLabels(item).subscribe((result) => {
|
||||
expect(result).toEqual([relationshipType.rightLabel]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRelatedItems', () => {
|
||||
it('should return the related items', () => {
|
||||
service.getRelatedItems(item).subscribe((result) => {
|
||||
@@ -146,7 +140,6 @@ describe('RelationshipService', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function getRemotedataObservable(obj: any): Observable<RemoteData<any>> {
|
||||
|
@@ -62,15 +62,6 @@ export class RelationshipService extends DataService<Relationship> {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a relationship by its UUID
|
||||
* @param uuid
|
||||
*/
|
||||
findById(uuid: string): Observable<RemoteData<Relationship>> {
|
||||
const href$ = this.getRelationshipEndpoint(uuid);
|
||||
return this.rdbService.buildSingle<Relationship>(href$);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a delete request for a relationship by ID
|
||||
* @param id
|
||||
|
@@ -12,7 +12,6 @@ import {
|
||||
import { SearchFiltersState } from '../../../shared/search/search-filters/search-filter/search-filter.reducer';
|
||||
import { SearchFilterConfig } from '../../../shared/search/search-filter-config.model';
|
||||
import { FilterType } from '../../../shared/search/filter-type.model';
|
||||
import { SearchFixedFilterService } from './search-fixed-filter.service';
|
||||
import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { SortDirection, SortOptions } from '../../cache/models/sort-options.model';
|
||||
@@ -28,11 +27,6 @@ describe('SearchFilterService', () => {
|
||||
pageSize: 2
|
||||
});
|
||||
|
||||
const mockFixedFilterService: SearchFixedFilterService = {
|
||||
getQueryByFilterName: (filter: string) => {
|
||||
return observableOf(undefined)
|
||||
}
|
||||
} as SearchFixedFilterService
|
||||
const value1 = 'random value';
|
||||
// const value2 = 'another value';
|
||||
const store: Store<SearchFiltersState> = jasmine.createSpyObj('store', {
|
||||
@@ -70,7 +64,7 @@ describe('SearchFilterService', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
service = new SearchFilterService(store, routeServiceStub, mockFixedFilterService);
|
||||
service = new SearchFilterService(store, routeServiceStub);
|
||||
});
|
||||
|
||||
describe('when the initializeFilter method is triggered', () => {
|
||||
@@ -264,19 +258,6 @@ describe('SearchFilterService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the getCurrentFixedFilter method is called', () => {
|
||||
const filter = 'fixedFilterQuery';
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(routeServiceStub, 'getRouteParameterValue').and.returnValue(observableOf(filter));
|
||||
spyOn(mockFixedFilterService, 'getQueryByFilterName').and.returnValue(observableOf(filter));
|
||||
service.getCurrentFixedFilter().subscribe();
|
||||
});
|
||||
|
||||
it('should call getQueryByFilterName on the fixed-filter service with the correct filter', () => {
|
||||
expect(mockFixedFilterService.getQueryByFilterName).toHaveBeenCalledWith(filter);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the getCurrentView method is called', () => {
|
||||
beforeEach(() => {
|
||||
|
@@ -39,10 +39,7 @@ import {
|
||||
} from '@ng-dynamic-forms/ui-ng-bootstrap';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import {
|
||||
DsDynamicFormControlContainerComponent,
|
||||
dsDynamicFormControlMapFn
|
||||
} from './ds-dynamic-form-control-container.component';
|
||||
import { DsDynamicFormControlContainerComponent, dsDynamicFormControlMapFn } from './ds-dynamic-form-control-container.component';
|
||||
import { SharedModule } from '../../../shared.module';
|
||||
import { DynamicDsDatePickerModel } from './models/date-picker/date-picker.model';
|
||||
import { DynamicRelationGroupModel } from './models/relation-group/dynamic-relation-group.model';
|
||||
@@ -65,10 +62,10 @@ import { DsDynamicFormArrayComponent } from './models/array-group/dynamic-form-a
|
||||
import { DsDynamicFormGroupComponent } from './models/form-group/dynamic-form-group.component';
|
||||
import { DsDynamicRelationGroupComponent } from './models/relation-group/dynamic-relation-group.components';
|
||||
import { DsDatePickerInlineComponent } from './models/date-picker-inline/dynamic-date-picker-inline.component';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { RelationshipService } from '../../../../core/data/relationship.service';
|
||||
import { SelectableListService } from '../../../object-list/selectable-list/selectable-list.service';
|
||||
import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
|
||||
describe('DsDynamicFormControlContainerComponent test suite', () => {
|
||||
|
||||
@@ -164,7 +161,8 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
|
||||
DsDynamicFormControlContainerComponent,
|
||||
DynamicFormService,
|
||||
{ provide: RelationshipService, useValue: {} },
|
||||
{ provide: SelectableListService, useValue: {} }
|
||||
{ provide: SelectableListService, useValue: {} },
|
||||
{ provide: ItemDataService, useValue: {} }
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents().then(() => {
|
||||
|
@@ -9,6 +9,7 @@ export function getMockRequestService(requestEntry$: Observable<RequestEntry> =
|
||||
getByHref: requestEntry$,
|
||||
getByUUID: requestEntry$,
|
||||
uriEncodeBody: jasmine.createSpy('uriEncodeBody'),
|
||||
hasByHrefObservable: observableOf(false),
|
||||
/* tslint:disable:no-empty */
|
||||
removeByHrefSubstring: () => {}
|
||||
/* tslint:enable:no-empty */
|
||||
|
@@ -2,16 +2,18 @@ import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core
|
||||
import { ObjectListComponent } from './object-list.component';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { SelectableListService } from './selectable-list/selectable-list.service';
|
||||
|
||||
describe('ObjectListComponent', () => {
|
||||
let comp: ObjectListComponent;
|
||||
let fixture: ComponentFixture<ObjectListComponent>;
|
||||
const testEvent = {test: 'test'};
|
||||
const testEvent = { test: 'test' };
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
declarations: [ObjectListComponent],
|
||||
providers: [{ provide: SelectableListService, useValue: {} }],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ObjectListComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
|
@@ -11,6 +11,7 @@ import { SearchServiceStub } from '../../testing/search-service-stub';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../../+my-dspace-page/my-dspace-page.component';
|
||||
import { SearchService } from '../../../core/shared/search/search.service';
|
||||
import { SearchConfigurationServiceStub } from '../../testing/search-configuration-service-stub';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
describe('SearchLabelsComponent', () => {
|
||||
let comp: SearchLabelsComponent;
|
||||
@@ -35,7 +36,7 @@ describe('SearchLabelsComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule],
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule, RouterTestingModule],
|
||||
declarations: [SearchLabelsComponent, ObjectKeysPipe],
|
||||
providers: [
|
||||
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) },
|
||||
|
@@ -118,11 +118,11 @@ const testFormConfiguration = {
|
||||
const testFormModel = [
|
||||
new DynamicRowGroupModel({
|
||||
id: 'df-row-group-config-1',
|
||||
group: [new DsDynamicInputModel({ id: 'dc.title' })],
|
||||
group: [new DsDynamicInputModel({ id: 'dc.title', workspaceItem: new WorkspaceItem(), repeatable: false })],
|
||||
}),
|
||||
new DynamicRowGroupModel({
|
||||
id: 'df-row-group-config-2',
|
||||
group: [new DsDynamicInputModel({ id: 'dc.contributor' })],
|
||||
group: [new DsDynamicInputModel({ id: 'dc.contributor', workspaceItem: new WorkspaceItem(), repeatable: false })],
|
||||
})
|
||||
];
|
||||
|
||||
|
@@ -3,15 +3,7 @@ import { HttpHeaders } from '@angular/common/http';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Observable, of as observableOf, Subscription, timer as observableTimer } from 'rxjs';
|
||||
import {
|
||||
catchError,
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
find,
|
||||
first,
|
||||
map,
|
||||
startWith
|
||||
} from 'rxjs/operators';
|
||||
import { catchError, distinctUntilChanged, filter, find, first, map, startWith } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
@@ -29,12 +21,7 @@ import {
|
||||
SaveSubmissionSectionFormAction,
|
||||
SetActiveSectionAction
|
||||
} from './objects/submission-objects.actions';
|
||||
import {
|
||||
SubmissionObjectEntry,
|
||||
SubmissionSectionEntry,
|
||||
SubmissionSectionError,
|
||||
SubmissionSectionObject
|
||||
} from './objects/submission-objects.reducer';
|
||||
import { SubmissionObjectEntry, SubmissionSectionEntry, SubmissionSectionError, SubmissionSectionObject } from './objects/submission-objects.reducer';
|
||||
import { submissionObjectFromIdSelector } from './selectors';
|
||||
import { GlobalConfig } from '../../config/global-config.interface';
|
||||
import { GLOBAL_CONFIG } from '../../config';
|
||||
@@ -51,11 +38,7 @@ import { WorkspaceitemSectionsObject } from '../core/submission/models/workspace
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
import { ErrorResponse } from '../core/cache/response.models';
|
||||
import { RemoteDataError } from '../core/data/remote-data-error';
|
||||
import {
|
||||
createFailedRemoteDataObject$,
|
||||
createSuccessfulRemoteDataObject,
|
||||
createSuccessfulRemoteDataObject$
|
||||
} from '../shared/testing/utils';
|
||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject } from '../shared/testing/utils';
|
||||
|
||||
/**
|
||||
* A service that provides methods used in submission process.
|
||||
@@ -131,7 +114,7 @@ export class SubmissionService {
|
||||
let headers = new HttpHeaders();
|
||||
headers = headers.append('Content-Type', 'text/uri-list');
|
||||
options.headers = headers;
|
||||
return this.restService.postToEndpoint(this.workspaceLinkPath, selfUrl, null, options) as Observable<SubmissionObject[]>;
|
||||
return this.restService.postToEndpoint(this.workflowLinkPath, selfUrl, null, options) as Observable<SubmissionObject[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user