Skip to content
Snippets Groups Projects
Commit dd039646 authored by lotte's avatar lotte
Browse files

fixed tests except for iterator issue in data services

parent 8bf241c1
Branches
Tags
No related merge requests found
......@@ -114,9 +114,8 @@ describe('authReducer', () => {
authToken: mockTokenInfo,
loaded: false,
error: undefined,
loading: false,
info: undefined,
user: EPersonMock
loading: true,
info: undefined
};
expect(newState).toEqual(state);
});
......
......@@ -29,8 +29,10 @@ describe('BaseResponseParsingService', () => {
const requestUUID = 'request-uuid';
const requestHref = 'request-href';
const request = new GetRequest(requestUUID, requestHref);
let obj: CacheableObject;
beforeEach(() => {
obj = undefined;
objectCache = jasmine.createSpyObj('objectCache', {
add: {}
});
......@@ -38,8 +40,6 @@ describe('BaseResponseParsingService', () => {
});
describe('cache', () => {
let obj: CacheableObject;
describe('when the object is undefined', () => {
it('should not throw an error', () => {
expect(() => { service.cache(obj, request, {}) }).not.toThrow();
......
......@@ -34,12 +34,12 @@ describe('DsoRedirectDataService', () => {
const http = {} as HttpClient;
const comparator = {} as any;
const objectCache = {} as ObjectCacheService;
let setup;
beforeEach(() => {
scheduler = getTestScheduler();
halService = jasmine.createSpyObj('halService', {
getEndpoint: cold('a', {a: pidLink})
getEndpoint: cold('a', { a: pidLink })
});
requestService = jasmine.createSpyObj('requestService', {
generateRequestId: requestUUID,
......@@ -60,29 +60,26 @@ describe('DsoRedirectDataService', () => {
}
};
setup = () => {
rdbService = jasmine.createSpyObj('rdbService', {
buildSingle: cold('a', {
a: remoteData
})
});
service = new DsoRedirectDataService(
requestService,
rdbService,
store,
objectCache,
halService,
notificationsService,
http,
comparator,
router
);
}
rdbService = jasmine.createSpyObj('rdbService', {
buildSingle: cold('a', {
a: remoteData
})
});
service = new DsoRedirectDataService(
requestService,
rdbService,
store,
objectCache,
halService,
notificationsService,
http,
comparator,
router
);
});
describe('findById', () => {
it('should call HALEndpointService with the path to the pid endpoint', () => {
setup();
scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE));
scheduler.flush();
......@@ -90,7 +87,6 @@ describe('DsoRedirectDataService', () => {
});
it('should call HALEndpointService with the path to the dso endpoint', () => {
setup();
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID));
scheduler.flush();
......@@ -98,7 +94,6 @@ describe('DsoRedirectDataService', () => {
});
it('should call HALEndpointService with the path to the dso endpoint when identifier type not specified', () => {
setup();
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID));
scheduler.flush();
......@@ -106,7 +101,6 @@ describe('DsoRedirectDataService', () => {
});
it('should configure the proper FindByIDRequest for uuid', () => {
setup();
scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID));
scheduler.flush();
......@@ -114,7 +108,6 @@ describe('DsoRedirectDataService', () => {
});
it('should configure the proper FindByIDRequest for handle', () => {
setup();
scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE));
scheduler.flush();
......@@ -123,7 +116,6 @@ describe('DsoRedirectDataService', () => {
it('should navigate to item route', () => {
remoteData.payload.type = 'item';
setup();
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
// The framework would normally subscribe but do it here so we can test navigation.
redir.subscribe();
......@@ -134,7 +126,6 @@ describe('DsoRedirectDataService', () => {
it('should navigate to collections route', () => {
remoteData.payload.type = 'collection';
setup();
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
redir.subscribe();
scheduler.schedule(() => redir);
......@@ -144,7 +135,6 @@ describe('DsoRedirectDataService', () => {
it('should navigate to communities route', () => {
remoteData.payload.type = 'community';
setup();
const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE);
redir.subscribe();
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') {
return observableOf(EPersonMock);
return observableOf(EPersonMock._links.self.href);
} else {
throw(new Error('Message Error test'));
}
}
public retrieveAuthenticatedUserByHref(href: string): Observable<EPerson> {
return observableOf(EPersonMock);
}
public buildAuthHeader(token?: AuthTokenInfo): string {
return `Bearer ${token.accessToken}`;
}
......@@ -102,8 +106,4 @@ export class AuthServiceStub {
isAuthenticated() {
return observableOf(true);
}
redirectAfterLoginSuccess() {
return;
}
}
......@@ -135,7 +135,6 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
protected sectionService: SectionsService,
protected submissionService: SubmissionService,
protected translate: TranslateService,
protected workspaceItemDataService: WorkspaceitemDataService,
@Inject('collectionIdProvider') public injectedCollectionId: string,
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
@Inject('submissionIdProvider') public injectedSubmissionId: string) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment