salix/modules/ticket/front/card/index.spec.js

37 lines
1.3 KiB
JavaScript

import './index';
describe('Ticket', () => {
describe('Component vnTicketCard', () => {
let controller;
let $state;
let $httpBackend;
beforeEach(ngModule('ticket'));
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
$state = _$state_;
$state.params.id = 1;
$httpBackend = _$httpBackend_;
controller = $componentController('vnTicketCard', {$state});
}));
describe('getCard()', () => {
it('should perform a GET query and define the ticket property on controller', () => {
let filter = controller.filter;
filter = encodeURIComponent(JSON.stringify(filter));
$httpBackend.when('GET', `/ticket/api/Tickets/1?filter=${filter}`).respond({id: 1, client: {id: 1}});
$httpBackend.expect('GET', `/ticket/api/Tickets/1?filter=${filter}`);
$httpBackend.when('GET', `/ticket/api/Clients/1/getDebt`).respond();
$httpBackend.expect('GET', `/ticket/api/Clients/1/getDebt`);
controller.getCard();
$httpBackend.flush();
expect(controller.ticket).toBeDefined();
expect(controller.ticket.id).toEqual(1);
});
});
});
});