diff --git a/client/client/src/descriptor-popover/index.spec.js b/client/client/src/descriptor-popover/index.spec.js new file mode 100644 index 000000000..6f55db527 --- /dev/null +++ b/client/client/src/descriptor-popover/index.spec.js @@ -0,0 +1,49 @@ +import './index'; + +describe('Client', () => { + describe('Component vnClientDescriptorPopover', () => { + let $componentController; + let $httpBackend; + let $scope; + let controller; + let $element; + + beforeEach(() => { + angular.mock.module('client'); + }); + + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { + $componentController = _$componentController_; + $httpBackend = _$httpBackend_; + $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); + $element = angular.element(`
`); + $scope = $rootScope.$new(); + controller = $componentController('vnClientDescriptorPopover', {$scope: $scope, $element: $element}); + })); + + describe('_getClientDebt()', () => { + it(`should perform a get query to store the client debt into the controller`, () => { + let clientFk = 1; + $httpBackend.when('GET', `/client/api/Clients/${clientFk}/getDebt`).respond({debt: 100}); + $httpBackend.expect('GET', `/client/api/Clients/${clientFk}/getDebt`); + controller._getClientDebt(clientFk); + $httpBackend.flush(); + + expect(controller.clientDebt).toEqual(100); + }); + }); + + describe('_getClient()', () => { + it(`should perform a get query to store the client data into the controller`, () => { + let clientFk = 1; + let response = {id: 1, name: 'name'}; + $httpBackend.when('GET', `/client/api/Clients/${clientFk}/card`).respond(response); + $httpBackend.expect('GET', `/client/api/Clients/${clientFk}/card`); + controller._getClient(clientFk); + $httpBackend.flush(); + + expect(controller.client).toEqual(response); + }); + }); + }); +}); diff --git a/services/order/common/methods/order/specs/getTotal.spec.js b/services/order/common/methods/order/specs/getTotal.spec.js index a51825250..d264f0c71 100644 --- a/services/order/common/methods/order/specs/getTotal.spec.js +++ b/services/order/common/methods/order/specs/getTotal.spec.js @@ -1,7 +1,7 @@ const app = require(`../../../../server/server`); describe('order getTotal()', () => { - it('should call the getTaxes method and return undefined if its called with a string', async() => { + it('should return the total', async() => { let result = await app.models.Order.getTotal(1); expect(result.total).toEqual(14.45);