diff --git a/modules/invoiceIn/front/card/index.spec.js b/modules/invoiceIn/front/card/index.spec.js new file mode 100644 index 0000000000..70f10f6b15 --- /dev/null +++ b/modules/invoiceIn/front/card/index.spec.js @@ -0,0 +1,27 @@ +import './index.js'; + +describe('vnInvoiceIn', () => { + let controller; + let $httpBackend; + let data = {id: 1, name: 'fooName'}; + + beforeEach(ngModule('invoiceIn')); + + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { + $httpBackend = _$httpBackend_; + + let $element = angular.element('
'); + controller = $componentController('vnInvoiceInCard', {$element}); + + $stateParams.id = data.id; + $httpBackend.whenRoute('GET', 'InvoiceIns/:id').respond(data); + })); + + it('should request data and set it on the controller', () => { + controller.reload(); + $httpBackend.flush(); + + expect(controller.invoiceIn).toEqual(data); + }); +}); + diff --git a/modules/invoiceIn/front/descriptor/index.spec.js b/modules/invoiceIn/front/descriptor/index.spec.js new file mode 100644 index 0000000000..df72f5b45e --- /dev/null +++ b/modules/invoiceIn/front/descriptor/index.spec.js @@ -0,0 +1,26 @@ +import './index'; + +describe('vnInvoiceInDescriptor', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('invoiceIn')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnInvoiceInDescriptor', {$element: null}); + })); + + 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(`InvoiceIns/${id}`).respond(response); + controller.id = id; + $httpBackend.flush(); + + expect(controller.invoiceIn).toEqual(response); + }); + }); +}); diff --git a/modules/invoiceOut/front/card/index.spec.js b/modules/invoiceOut/front/card/index.spec.js new file mode 100644 index 0000000000..2a8d576dc2 --- /dev/null +++ b/modules/invoiceOut/front/card/index.spec.js @@ -0,0 +1,27 @@ +import './index.js'; + +describe('vnInvoiceOut', () => { + let controller; + let $httpBackend; + let data = {id: 1, name: 'fooName'}; + + beforeEach(ngModule('invoiceOut')); + + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { + $httpBackend = _$httpBackend_; + + let $element = angular.element('
'); + controller = $componentController('vnInvoiceOutCard', {$element}); + + $stateParams.id = data.id; + $httpBackend.whenRoute('GET', 'InvoiceOuts/:id').respond(data); + })); + + it('should request data and set it on the controller', () => { + controller.reload(); + $httpBackend.flush(); + + expect(controller.invoiceOut).toEqual(data); + }); +}); + diff --git a/modules/invoiceOut/front/descriptor/index.spec.js b/modules/invoiceOut/front/descriptor/index.spec.js new file mode 100644 index 0000000000..987763b0a6 --- /dev/null +++ b/modules/invoiceOut/front/descriptor/index.spec.js @@ -0,0 +1,26 @@ +import './index'; + +describe('vnInvoiceOutDescriptor', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('invoiceOut')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnInvoiceOutDescriptor', {$element: null}); + })); + + 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); + }); + }); +});