#515 descriptor client unit test

This commit is contained in:
Carlos Jimenez 2018-08-16 07:40:25 +02:00
parent 8f385798b6
commit b4321816be
1 changed files with 36 additions and 0 deletions

View File

@ -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);
});
});
});
});