diff --git a/modules/invoiceOut/front/summary/index.html b/modules/invoiceOut/front/summary/index.html index 0dd9bfe0b..0406a39c5 100644 --- a/modules/invoiceOut/front/summary/index.html +++ b/modules/invoiceOut/front/summary/index.html @@ -1,9 +1,7 @@ + data="tickets">
@@ -56,7 +54,7 @@

Ticket

- + Ticket id diff --git a/modules/invoiceOut/front/summary/index.js b/modules/invoiceOut/front/summary/index.js index c0f8b4825..2446e986a 100644 --- a/modules/invoiceOut/front/summary/index.js +++ b/modules/invoiceOut/front/summary/index.js @@ -5,8 +5,10 @@ import './style.scss'; class Controller extends Summary { set invoiceOut(value) { this._invoiceOut = value; - if (value && value.id) + if (value && value.id) { this.getSummary(); + this.getTickets(); + } } get invoiceOut() { @@ -17,6 +19,14 @@ class Controller extends Summary { return this.$http.get(`InvoiceOuts/${this.invoiceOut.id}/summary`) .then(res => this.summary = res.data); } + + getTickets() { + this.$.$applyAsync(() => { + const query = `InvoiceOuts/${this.invoiceOut.id}/getTickets`; + this.$.ticketsModel.url = query; + this.$.ticketsModel.refresh(); + }); + } } ngModule.vnComponent('vnInvoiceOutSummary', { diff --git a/modules/invoiceOut/front/summary/index.spec.js b/modules/invoiceOut/front/summary/index.spec.js index fadf0ad89..be6ad0a18 100644 --- a/modules/invoiceOut/front/summary/index.spec.js +++ b/modules/invoiceOut/front/summary/index.spec.js @@ -1,4 +1,5 @@ import './index.js'; +import crudModel from 'core/mocks/crud-model'; describe('InvoiceOut', () => { describe('Component summary', () => { @@ -13,17 +14,30 @@ describe('InvoiceOut', () => { $scope = $rootScope.$new(); const $element = angular.element(''); controller = $componentController('vnInvoiceOutSummary', {$element, $scope}); - controller.invoiceOut = {id: 1}; + controller._invoiceOut = {id: 1}; + controller.$.ticketsModel = crudModel; })); describe('getSummary()', () => { it('should perform a query to set summary', () => { - $httpBackend.when('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for'); + $httpBackend.expect('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for'); controller.getSummary(); $httpBackend.flush(); expect(controller.summary).toEqual('the data you are looking for'); }); }); + + describe('getTickets()', () => { + it('should perform a and then call to the ticketModel refresh() method', () => { + jest.spyOn(controller.$.ticketsModel, 'refresh'); + + controller.getTickets(); + $scope.$apply(); + + expect(controller.$.ticketsModel.url).toEqual('InvoiceOuts/1/getTickets'); + expect(controller.$.ticketsModel.refresh).toHaveBeenCalledWith(); + }); + }); }); });