Merge "Pass whole selected entity to deleteEntity callback"

This commit is contained in:
Zuul 2018-04-08 15:18:19 +00:00 committed by Gerrit Code Review
commit 9a0b11ee26
2 changed files with 7 additions and 6 deletions

View File

@ -71,6 +71,7 @@
* @param {function} context.deleteEntity
* The function that should be called to delete each entity.
* The first argument is the id of the Entity to delete.
* The second argument is the Entity itself.
* Note: This callback might need to suppress errors on the
* alert service.
*
@ -100,7 +101,7 @@
}
function deleteEntityPromise(entity) {
return {promise: context.deleteEntity(entity.id), context: entity};
return {promise: context.deleteEntity(entity.id, entity), context: entity};
}
function notify(result) {

View File

@ -117,8 +117,8 @@
$scope.$apply();
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1');
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('2');
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1', {name: 'entity1', id: '1'});
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('2', {name: 'entity2', id: '2'});
expect(toastService.add).toHaveBeenCalledWith('success', 'Deleted : entity1, entity2.');
expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_passed', [ '1', '2' ]);
});
@ -134,7 +134,7 @@
$scope.$apply();
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad');
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad', {name: 'entity1', id: 'bad'});
expect(toastService.add).toHaveBeenCalledWith('error', 'Unable to delete: entity1.');
expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_failed', ['bad']);
});
@ -153,8 +153,8 @@
$scope.$apply();
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad');
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1');
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad', {name: 'bad_entity', id: 'bad'});
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1', {name: 'entity2', id: '1'});
expect(toastService.add).toHaveBeenCalledWith('success', 'Deleted : entity2.');
expect(toastService.add).toHaveBeenCalledWith('error', 'Unable to delete: bad_entity.');
expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_passed', ['1']);