test front checkToBook
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javi Gallego 2022-01-19 14:21:19 +01:00
parent 3c8e6a16a2
commit 563b93a7be
2 changed files with 41 additions and 2 deletions

View File

@ -71,7 +71,7 @@ class Controller extends Descriptor {
} }
}}) }})
.then(res => { .then(res => {
if (res) if (res.data)
message += 'future payments'; message += 'future payments';
}) })
@ -79,7 +79,7 @@ class Controller extends Descriptor {
if (message.length) if (message.length)
this.$.confirmToBookAnyway.show(); this.$.confirmToBookAnyway.show();
else else
onAcceptToBook(); this.onAcceptToBook();
}); });
} }

View File

@ -35,4 +35,43 @@ describe('vnInvoiceInDescriptor', () => {
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('InvoiceIn booked'); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('InvoiceIn booked');
}); });
}); });
describe('checktoBook()', () => {
it(`should show both warning messages`, () => {
controller.$.confirmToBookAnyway = {show: () => {}};
jest.spyOn(controller.$.confirmToBookAnyway, 'show');
const invoceInId = 1;
const data = {
totalDueDay: 'an amount',
totalTaxableBase: 'distinct amount'
};
$httpBackend.expectGET(`InvoiceIns/${invoceInId}/getTotals`).respond(data);
$httpBackend.expectGET(`InvoiceInDueDays/count`).respond();
controller.checktoBook();
$httpBackend.flush();
expect(controller.$.confirmToBookAnyway.show).toHaveBeenCalledWith();
});
it(`should call onAcceptToBook`, () => {
controller.onAcceptToBook = jest.fn();
const invoceInId = 1;
const data = {
totalDueDay: 'same amount',
totalTaxableBase: 'same amount'
};
$httpBackend.expectGET(`InvoiceIns/${invoceInId}/getTotals`).respond(data);
$httpBackend.expectGET(`InvoiceInDueDays/count`).respond();
controller.checktoBook();
$httpBackend.flush();
expect(controller.onAcceptToBook).toHaveBeenCalledWith();
});
});
}); });