mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Merge branch 'master' into w2p-58789_Metadata-Registry-UI-Part-2
Conflicts: src/app/+admin/admin-registries/metadata-schema/metadata-schema.component.ts src/app/+community-page/community-page.component.html src/app/app.reducer.ts src/app/core/auth/server-auth.service.ts src/app/core/core.module.ts src/app/core/data/item-data.service.spec.ts src/app/core/data/item-data.service.ts src/app/core/index/index.effects.ts src/app/core/index/index.reducer.spec.ts src/app/core/index/index.reducer.ts src/app/core/shared/operators.spec.ts src/app/core/shared/operators.ts src/app/header/header.component.spec.ts
This commit is contained in:
@@ -7,9 +7,12 @@ import { RequestService } from '../data/request.service';
|
||||
import {
|
||||
configureRequest,
|
||||
filterSuccessfulResponses,
|
||||
getAllSucceededRemoteData,
|
||||
getRemoteDataPayload, getRequestFromRequestHref, getRequestFromRequestUUID,
|
||||
getResourceLinksFromResponse, getResponseFromEntry,
|
||||
getSucceededRemoteData
|
||||
} from './operators';
|
||||
import {RemoteData} from '../data/remote-data';
|
||||
|
||||
describe('Core Module - RxJS Operators', () => {
|
||||
let scheduler: TestScheduler;
|
||||
@@ -48,7 +51,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
const result = source.pipe(getRequestFromRequestHref(requestService));
|
||||
const expected = cold('a', { a: new RequestEntry() });
|
||||
|
||||
expect(result).toBeObservable(expected)
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should use the requestService to fetch the request by its self link', () => {
|
||||
@@ -58,7 +61,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
scheduler.schedule(() => source.pipe(getRequestFromRequestHref(requestService)).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
expect(requestService.getByHref).toHaveBeenCalledWith(testRequestHref)
|
||||
expect(requestService.getByHref).toHaveBeenCalledWith(testRequestHref);
|
||||
});
|
||||
|
||||
it('shouldn\'t return anything if there is no request matching the self link', () => {
|
||||
@@ -68,7 +71,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
const result = source.pipe(getRequestFromRequestHref(requestService));
|
||||
const expected = cold('-');
|
||||
|
||||
expect(result).toBeObservable(expected)
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,7 +84,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
const result = source.pipe(getRequestFromRequestUUID(requestService));
|
||||
const expected = cold('a', { a: new RequestEntry() });
|
||||
|
||||
expect(result).toBeObservable(expected)
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should use the requestService to fetch the request by its request uuid', () => {
|
||||
@@ -91,7 +94,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
scheduler.schedule(() => source.pipe(getRequestFromRequestUUID(requestService)).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
expect(requestService.getByUUID).toHaveBeenCalledWith(testRequestUUID)
|
||||
expect(requestService.getByUUID).toHaveBeenCalledWith(testRequestUUID);
|
||||
});
|
||||
|
||||
it('shouldn\'t return anything if there is no request matching the request uuid', () => {
|
||||
@@ -101,7 +104,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
const result = source.pipe(getRequestFromRequestUUID(requestService));
|
||||
const expected = cold('-');
|
||||
|
||||
expect(result).toBeObservable(expected)
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,7 +114,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
const result = source.pipe(filterSuccessfulResponses());
|
||||
const expected = cold('a--d-', testResponses);
|
||||
|
||||
expect(result).toBeObservable(expected)
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -124,7 +127,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
d: testRCEs.d.response.resourceSelfLinks
|
||||
});
|
||||
|
||||
expect(result).toBeObservable(expected)
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -136,7 +139,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
scheduler.schedule(() => source.pipe(configureRequest(requestService)).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
expect(requestService.configure).toHaveBeenCalledWith(testRequest)
|
||||
expect(requestService.configure).toHaveBeenCalledWith(testRequest);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -149,7 +152,7 @@ describe('Core Module - RxJS Operators', () => {
|
||||
a: testRD.a.payload,
|
||||
});
|
||||
|
||||
expect(result).toBeObservable(expected)
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -168,4 +171,41 @@ describe('Core Module - RxJS Operators', () => {
|
||||
expect(result).toBeObservable(expected)
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSucceededRemoteData', () => {
|
||||
it('should return the first() hasSucceeded RemoteData Observable', () => {
|
||||
const testRD = {
|
||||
a: new RemoteData(false, false, true, null, undefined),
|
||||
b: new RemoteData(false, false, false, null, 'b'),
|
||||
c: new RemoteData(false, false, undefined, null, 'c'),
|
||||
d: new RemoteData(false, false, true, null, 'd'),
|
||||
e: new RemoteData(false, false, true, null, 'e'),
|
||||
};
|
||||
const source = hot('abcde', testRD);
|
||||
const result = source.pipe(getSucceededRemoteData());
|
||||
|
||||
result.subscribe((value) => expect(value)
|
||||
.toEqual(new RemoteData(false, false, true, null, 'd')));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
describe('getAllSucceededRemoteData', () => {
|
||||
it('should return all hasSucceeded RemoteData Observables', () => {
|
||||
const testRD = {
|
||||
a: new RemoteData(false, false, true, null, undefined),
|
||||
b: new RemoteData(false, false, false, null, 'b'),
|
||||
c: new RemoteData(false, false, undefined, null, 'c'),
|
||||
d: new RemoteData(false, false, true, null, 'd'),
|
||||
e: new RemoteData(false, false, true, null, 'e'),
|
||||
};
|
||||
const source = hot('abcde', testRD);
|
||||
const result = source.pipe(getAllSucceededRemoteData());
|
||||
const expected = cold('---de', testRD);
|
||||
|
||||
expect(result).toBeObservable(expected);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user