2021-03-03 06:44:09 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('vnInvoiceOutDescriptor', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
2021-03-15 15:35:55 +00:00
|
|
|
const invoiceOut = {id: 1};
|
2021-03-03 06:44:09 +00:00
|
|
|
|
|
|
|
beforeEach(ngModule('invoiceOut'));
|
|
|
|
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
controller = $componentController('vnInvoiceOutDescriptor', {$element: null});
|
|
|
|
}));
|
|
|
|
|
2021-03-15 15:35:55 +00:00
|
|
|
describe('createInvoicePdf()', () => {
|
|
|
|
it('should make a query and show a success snackbar', () => {
|
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
|
|
|
|
controller.invoiceOut = invoiceOut;
|
|
|
|
|
2021-10-01 12:31:42 +00:00
|
|
|
$httpBackend.whenGET(`InvoiceOuts/${invoiceOut.id}`).respond();
|
2021-03-15 15:35:55 +00:00
|
|
|
$httpBackend.expectPOST(`InvoiceOuts/${invoiceOut.id}/createPdf`).respond();
|
|
|
|
controller.createInvoicePdf();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-03-03 06:44:09 +00:00
|
|
|
describe('loadData()', () => {
|
|
|
|
it(`should perform a get query to store the invoice in data into the controller`, () => {
|
|
|
|
const id = 1;
|
|
|
|
const response = {id: 1};
|
|
|
|
|
|
|
|
$httpBackend.expectGET(`InvoiceOuts/${id}`).respond(response);
|
|
|
|
controller.id = id;
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.invoiceOut).toEqual(response);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|