mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Fix objectUpdatesReducer no expectation tests
Added a expect().nothing() to the test who don't expect anything but just ensure that no error is thrown
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
SetEditableFieldUpdateAction,
|
||||
SetValidFieldUpdateAction
|
||||
} from './object-updates.actions';
|
||||
import { OBJECT_UPDATES_TRASH_PATH, objectUpdatesReducer } from './object-updates.reducer';
|
||||
import { OBJECT_UPDATES_TRASH_PATH, objectUpdatesReducer, ObjectUpdatesState } from './object-updates.reducer';
|
||||
import { Relationship } from '../../shared/item-relationships/relationship.model';
|
||||
import { FieldChangeType } from './field-change-type.model';
|
||||
|
||||
@@ -56,7 +56,7 @@ const modDate = new Date(2010, 2, 11);
|
||||
const uuid = identifiable1.uuid;
|
||||
const url = 'test-object.url/edit';
|
||||
describe('objectUpdatesReducer', () => {
|
||||
const testState = {
|
||||
const testState: ObjectUpdatesState = {
|
||||
[url]: {
|
||||
fieldStates: {
|
||||
[identifiable1.uuid]: {
|
||||
@@ -79,9 +79,6 @@ describe('objectUpdatesReducer', () => {
|
||||
[identifiable2.uuid]: {
|
||||
field: {
|
||||
uuid: identifiable2.uuid,
|
||||
key: 'dc.titl',
|
||||
language: null,
|
||||
value: 'New title'
|
||||
},
|
||||
changeType: FieldChangeType.ADD
|
||||
}
|
||||
@@ -93,7 +90,7 @@ describe('objectUpdatesReducer', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const discardedTestState = {
|
||||
const discardedTestState: ObjectUpdatesState = {
|
||||
[url]: {
|
||||
fieldStates: {
|
||||
[identifiable1.uuid]: {
|
||||
@@ -139,9 +136,6 @@ describe('objectUpdatesReducer', () => {
|
||||
[identifiable2.uuid]: {
|
||||
field: {
|
||||
uuid: identifiable2.uuid,
|
||||
key: 'dc.titl',
|
||||
language: null,
|
||||
value: 'New title'
|
||||
},
|
||||
changeType: FieldChangeType.ADD
|
||||
}
|
||||
@@ -173,48 +167,80 @@ describe('objectUpdatesReducer', () => {
|
||||
const action = new InitializeFieldsAction(url, [identifiable1, identifiable2], modDate);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should perform the SET_EDITABLE_FIELD action without affecting the previous state', () => {
|
||||
const action = new SetEditableFieldUpdateAction(url, uuid, false);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should perform the ADD_FIELD action without affecting the previous state', () => {
|
||||
const action = new AddFieldUpdateAction(url, identifiable1update, FieldChangeType.UPDATE);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should perform the DISCARD action without affecting the previous state', () => {
|
||||
const action = new DiscardObjectUpdatesAction(url, null);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should perform the REINSTATE action without affecting the previous state', () => {
|
||||
const action = new ReinstateObjectUpdatesAction(url);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should perform the REMOVE action without affecting the previous state', () => {
|
||||
const action = new RemoveFieldUpdateAction(url, uuid);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should perform the REMOVE_FIELD action without affecting the previous state', () => {
|
||||
const action = new RemoveFieldUpdateAction(url, uuid);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should perform the SELECT_VIRTUAL_METADATA action without affecting the previous state', () => {
|
||||
const action = new SelectVirtualMetadataAction(url, relationship.uuid, identifiable1.uuid, true);
|
||||
// testState has already been frozen above
|
||||
objectUpdatesReducer(testState, action);
|
||||
|
||||
// no expect required, deepFreeze will ensure an exception is thrown if the state
|
||||
// is mutated, and any uncaught exception will cause the test to fail
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it('should initialize all fields when the INITIALIZE action is dispatched, based on the payload', () => {
|
||||
|
@@ -77,7 +77,7 @@ export interface DeleteRelationship extends RelationshipIdentifiable {
|
||||
*/
|
||||
export interface ObjectUpdatesEntry {
|
||||
fieldStates: FieldStates;
|
||||
fieldUpdates: FieldUpdates;
|
||||
fieldUpdates?: FieldUpdates;
|
||||
virtualMetadataSources: VirtualMetadataSources;
|
||||
lastModified: Date;
|
||||
patchOperationService?: GenericConstructor<PatchOperationService>;
|
||||
|
Reference in New Issue
Block a user