#515 descriptor client unit test
This commit is contained in:
parent
8f385798b6
commit
b4321816be
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue