2741 - Claim detail deletion visual fix #532
|
@ -86,16 +86,15 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showDeleteConfirm(index) {
|
showDeleteConfirm($index) {
|
||||||
this.sale = this.salesClaimed[index];
|
this.claimedIndex = $index;
|
||||||
this.$.confirm.show();
|
this.$.confirm.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteClaimedSale() {
|
deleteClaimedSale() {
|
||||||
let query = `ClaimBeginnings/${this.sale.id}`;
|
this.$.model.remove(this.claimedIndex);
|
||||||
this.$http.delete(query).then(() => {
|
this.$.model.save().then(() => {
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
this.$.model.remove(this.sale);
|
|
||||||
this.calculateTotals();
|
this.calculateTotals();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,13 +73,16 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('deleteClaimedSale()', () => {
|
describe('deleteClaimedSale()', () => {
|
||||||
it('should make a delete and call refresh and showSuccess', () => {
|
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, 'remove');
|
||||||
|
jest.spyOn(controller.$.model, 'save');
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
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();
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue