Merge pull request '2741 - Claim detail deletion visual fix' (#532) from 2741-claim_detail_delete into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #532
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2021-02-02 09:10:50 +00:00
commit 1f29d6be16
2 changed files with 11 additions and 9 deletions

View File

@ -86,16 +86,15 @@ class Controller extends Section {
});
}
showDeleteConfirm(index) {
this.sale = this.salesClaimed[index];
showDeleteConfirm($index) {
this.claimedIndex = $index;
this.$.confirm.show();
}
deleteClaimedSale() {
let query = `ClaimBeginnings/${this.sale.id}`;
this.$http.delete(query).then(() => {
this.$.model.remove(this.claimedIndex);
this.$.model.save().then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.$.model.remove(this.sale);
this.calculateTotals();
});
}

View File

@ -73,13 +73,16 @@ describe('claim', () => {
describe('deleteClaimedSale()', () => {
it('should make a delete and call refresh and showSuccess', () => {
controller.sale = {id: 1};
const claimedIndex = 1;
controller.claimedIndex = claimedIndex;
jest.spyOn(controller.$.model, 'remove');
jest.spyOn(controller.$.model, 'save');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectDELETE(`ClaimBeginnings/1`).respond('ok');
controller.deleteClaimedSale();
$httpBackend.flush();
controller.deleteClaimedSale();
expect(controller.$.model.remove).toHaveBeenCalledWith(claimedIndex);
expect(controller.$.model.save).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});