mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
[835] Auto-save in new Item Submission form breaks the form
Submission form Save button disabled when no pending operations are present
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { getTestScheduler } from 'jasmine-marbles';
|
||||
import { getTestScheduler, hot } from 'jasmine-marbles';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { SubmissionPatchRequest } from '../data/request.models';
|
||||
@@ -22,6 +21,7 @@ import {
|
||||
} from './json-patch-operations.actions';
|
||||
import { RequestEntry } from '../data/request.reducer';
|
||||
import { createFailedRemoteDataObject, createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
|
||||
import { _deepClone } from 'fast-json-patch/lib/helpers';
|
||||
|
||||
class TestService extends JsonPatchOperationsService<SubmitDataResponseDefinitionObject, SubmissionPatchRequest> {
|
||||
protected linkPath = '';
|
||||
@@ -196,6 +196,32 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('hasPendingOperations', () => {
|
||||
|
||||
it('should return true when there are pending operations', () => {
|
||||
|
||||
const expected = hot('(x|)', { x: true });
|
||||
|
||||
const result = service.hasPendingOperations(testJsonPatchResourceType);
|
||||
expect(result).toBeObservable(expected);
|
||||
|
||||
});
|
||||
|
||||
it('should return false when there are not pending operations', () => {
|
||||
|
||||
const mockStateNoOp = _deepClone(mockState);
|
||||
mockStateNoOp['json/patch'][testJsonPatchResourceType].children = [];
|
||||
store.select.and.returnValue(observableOf(mockStateNoOp['json/patch'][testJsonPatchResourceType]));
|
||||
|
||||
const expected = hot('(x|)', { x: false });
|
||||
|
||||
const result = service.hasPendingOperations(testJsonPatchResourceType);
|
||||
expect(result).toBeObservable(expected);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('jsonPatchByResourceID', () => {
|
||||
|
||||
it('should call submitJsonPatchOperations method', () => {
|
||||
|
Reference in New Issue
Block a user