mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 18:44:14 +00:00
fixed tests except for iterator issue in data services
This commit is contained in:
@@ -114,9 +114,8 @@ describe('authReducer', () => {
|
|||||||
authToken: mockTokenInfo,
|
authToken: mockTokenInfo,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
loading: false,
|
loading: true,
|
||||||
info: undefined,
|
info: undefined
|
||||||
user: EPersonMock
|
|
||||||
};
|
};
|
||||||
expect(newState).toEqual(state);
|
expect(newState).toEqual(state);
|
||||||
});
|
});
|
||||||
|
@@ -29,8 +29,10 @@ describe('BaseResponseParsingService', () => {
|
|||||||
const requestUUID = 'request-uuid';
|
const requestUUID = 'request-uuid';
|
||||||
const requestHref = 'request-href';
|
const requestHref = 'request-href';
|
||||||
const request = new GetRequest(requestUUID, requestHref);
|
const request = new GetRequest(requestUUID, requestHref);
|
||||||
|
let obj: CacheableObject;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
obj = undefined;
|
||||||
objectCache = jasmine.createSpyObj('objectCache', {
|
objectCache = jasmine.createSpyObj('objectCache', {
|
||||||
add: {}
|
add: {}
|
||||||
});
|
});
|
||||||
@@ -38,8 +40,6 @@ describe('BaseResponseParsingService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('cache', () => {
|
describe('cache', () => {
|
||||||
let obj: CacheableObject;
|
|
||||||
|
|
||||||
describe('when the object is undefined', () => {
|
describe('when the object is undefined', () => {
|
||||||
it('should not throw an error', () => {
|
it('should not throw an error', () => {
|
||||||
expect(() => { service.cache(obj, request, {}) }).not.toThrow();
|
expect(() => { service.cache(obj, request, {}) }).not.toThrow();
|
||||||
|
@@ -34,12 +34,12 @@ describe('DsoRedirectDataService', () => {
|
|||||||
const http = {} as HttpClient;
|
const http = {} as HttpClient;
|
||||||
const comparator = {} as any;
|
const comparator = {} as any;
|
||||||
const objectCache = {} as ObjectCacheService;
|
const objectCache = {} as ObjectCacheService;
|
||||||
let setup;
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
|
|
||||||
halService = jasmine.createSpyObj('halService', {
|
halService = jasmine.createSpyObj('halService', {
|
||||||
getEndpoint: cold('a', {a: pidLink})
|
getEndpoint: cold('a', { a: pidLink })
|
||||||
});
|
});
|
||||||
requestService = jasmine.createSpyObj('requestService', {
|
requestService = jasmine.createSpyObj('requestService', {
|
||||||
generateRequestId: requestUUID,
|
generateRequestId: requestUUID,
|
||||||
@@ -60,29 +60,26 @@ describe('DsoRedirectDataService', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
setup = () => {
|
rdbService = jasmine.createSpyObj('rdbService', {
|
||||||
rdbService = jasmine.createSpyObj('rdbService', {
|
buildSingle: cold('a', {
|
||||||
buildSingle: cold('a', {
|
a: remoteData
|
||||||
a: remoteData
|
})
|
||||||
})
|
});
|
||||||
});
|
service = new DsoRedirectDataService(
|
||||||
service = new DsoRedirectDataService(
|
requestService,
|
||||||
requestService,
|
rdbService,
|
||||||
rdbService,
|
store,
|
||||||
store,
|
objectCache,
|
||||||
objectCache,
|
halService,
|
||||||
halService,
|
notificationsService,
|
||||||
notificationsService,
|
http,
|
||||||
http,
|
comparator,
|
||||||
comparator,
|
router
|
||||||
router
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('findById', () => {
|
describe('findById', () => {
|
||||||
it('should call HALEndpointService with the path to the pid endpoint', () => {
|
it('should call HALEndpointService with the path to the pid endpoint', () => {
|
||||||
setup();
|
|
||||||
scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE));
|
scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
@@ -90,7 +87,6 @@ describe('DsoRedirectDataService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call HALEndpointService with the path to the dso endpoint', () => {
|
it('should call HALEndpointService with the path to the dso endpoint', () => {
|
||||||
setup();
|
|
||||||
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID));
|
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
@@ -98,7 +94,6 @@ describe('DsoRedirectDataService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call HALEndpointService with the path to the dso endpoint when identifier type not specified', () => {
|
it('should call HALEndpointService with the path to the dso endpoint when identifier type not specified', () => {
|
||||||
setup();
|
|
||||||
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID));
|
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
@@ -106,7 +101,6 @@ describe('DsoRedirectDataService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should configure the proper FindByIDRequest for uuid', () => {
|
it('should configure the proper FindByIDRequest for uuid', () => {
|
||||||
setup();
|
|
||||||
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID));
|
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
@@ -114,7 +108,6 @@ describe('DsoRedirectDataService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should configure the proper FindByIDRequest for handle', () => {
|
it('should configure the proper FindByIDRequest for handle', () => {
|
||||||
setup();
|
|
||||||
scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE));
|
scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
@@ -123,7 +116,6 @@ describe('DsoRedirectDataService', () => {
|
|||||||
|
|
||||||
it('should navigate to item route', () => {
|
it('should navigate to item route', () => {
|
||||||
remoteData.payload.type = 'item';
|
remoteData.payload.type = 'item';
|
||||||
setup();
|
|
||||||
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
|
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
|
||||||
// The framework would normally subscribe but do it here so we can test navigation.
|
// The framework would normally subscribe but do it here so we can test navigation.
|
||||||
redir.subscribe();
|
redir.subscribe();
|
||||||
@@ -134,7 +126,6 @@ describe('DsoRedirectDataService', () => {
|
|||||||
|
|
||||||
it('should navigate to collections route', () => {
|
it('should navigate to collections route', () => {
|
||||||
remoteData.payload.type = 'collection';
|
remoteData.payload.type = 'collection';
|
||||||
setup();
|
|
||||||
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
|
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
|
||||||
redir.subscribe();
|
redir.subscribe();
|
||||||
scheduler.schedule(() => redir);
|
scheduler.schedule(() => redir);
|
||||||
@@ -144,7 +135,6 @@ describe('DsoRedirectDataService', () => {
|
|||||||
|
|
||||||
it('should navigate to communities route', () => {
|
it('should navigate to communities route', () => {
|
||||||
remoteData.payload.type = 'community';
|
remoteData.payload.type = 'community';
|
||||||
setup();
|
|
||||||
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
|
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
|
||||||
redir.subscribe();
|
redir.subscribe();
|
||||||
scheduler.schedule(() => redir);
|
scheduler.schedule(() => redir);
|
||||||
|
@@ -29,14 +29,18 @@ export class AuthServiceStub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public authenticatedUser(token: AuthTokenInfo): Observable<EPerson> {
|
public authenticatedUser(token: AuthTokenInfo): Observable<string> {
|
||||||
if (token.accessToken === 'token_test') {
|
if (token.accessToken === 'token_test') {
|
||||||
return observableOf(EPersonMock);
|
return observableOf(EPersonMock._links.self.href);
|
||||||
} else {
|
} else {
|
||||||
throw(new Error('Message Error test'));
|
throw(new Error('Message Error test'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public retrieveAuthenticatedUserByHref(href: string): Observable<EPerson> {
|
||||||
|
return observableOf(EPersonMock);
|
||||||
|
}
|
||||||
|
|
||||||
public buildAuthHeader(token?: AuthTokenInfo): string {
|
public buildAuthHeader(token?: AuthTokenInfo): string {
|
||||||
return `Bearer ${token.accessToken}`;
|
return `Bearer ${token.accessToken}`;
|
||||||
}
|
}
|
||||||
@@ -102,8 +106,4 @@ export class AuthServiceStub {
|
|||||||
isAuthenticated() {
|
isAuthenticated() {
|
||||||
return observableOf(true);
|
return observableOf(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
redirectAfterLoginSuccess() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -135,7 +135,6 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
protected sectionService: SectionsService,
|
protected sectionService: SectionsService,
|
||||||
protected submissionService: SubmissionService,
|
protected submissionService: SubmissionService,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected workspaceItemDataService: WorkspaceitemDataService,
|
|
||||||
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
||||||
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
||||||
@Inject('submissionIdProvider') public injectedSubmissionId: string) {
|
@Inject('submissionIdProvider') public injectedSubmissionId: string) {
|
||||||
|
Reference in New Issue
Block a user