diff --git a/client/ticket/src/descriptor/index.spec.js b/client/ticket/src/descriptor/index.spec.js new file mode 100644 index 000000000..acea5bab9 --- /dev/null +++ b/client/ticket/src/descriptor/index.spec.js @@ -0,0 +1,36 @@ +import './index'; + +describe('Ticket', () => { + describe('Component vnTicketDescriptor', () => { + let $componentController; + let controller; + let $scope; + let $httpBackend; + + beforeEach(() => { + angular.mock.module('ticket'); + }); + + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { + $componentController = _$componentController_; + $httpBackend = _$httpBackend_; + $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); + $scope = $rootScope.$new(); + controller = $componentController('vnTicketDescriptor', {$scope: $scope}); + })); + + describe('getClientDebt()', () => { + it('should store the client debt into the controller', () => { + let clientFk = 101; + let response = {debt: 10}; + + $httpBackend.when('GET', `/client/api/Clients/${clientFk}/getDebt`).respond(response); + $httpBackend.expect('GET', `/client/api/Clients/${clientFk}/getDebt`); + controller.getClientDebt(clientFk); + $httpBackend.flush(); + + expect(controller.clientDebt).toEqual(response.debt); + }); + }); + }); +});