39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import './index';
|
|
|
|
describe('vnInvoiceInDescriptor', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
|
|
beforeEach(ngModule('invoiceIn'));
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
const $element = angular.element('<vn-invoice-in-descriptor></vn-invoice-in-descriptor>');
|
|
|
|
controller = $componentController('vnInvoiceInDescriptor', {$element});
|
|
controller.invoiceIn = {id: 1};
|
|
$httpBackend.when('GET', `InvoiceIns/${controller.invoiceIn.id}`).respond({id: 1});
|
|
}));
|
|
|
|
describe('loadData()', () => {
|
|
it(`should perform a get query to store the invoice in data into the controller`, () => {
|
|
expect(controller.invoiceIn).toEqual({id: 1});
|
|
});
|
|
});
|
|
|
|
describe('onAcceptToBook()', () => {
|
|
it(`should perform a post query to book the invoice`, () => {
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
controller.$state.reload = jest.fn();
|
|
|
|
const id = 1;
|
|
|
|
$httpBackend.expectPOST(`InvoiceIns/${id}/toBook`).respond();
|
|
controller.onAcceptToBook();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('InvoiceIn booked');
|
|
});
|
|
});
|
|
});
|