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

39 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-08-09 12:42:02 +00:00
import './index';
describe('Ticket', () => {
describe('Component vnTicketCard', () => {
let controller;
let $state;
let $httpBackend;
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('ticket', $translateProvider => {
$translateProvider.translations('en', {});
}));
2018-08-09 12:42:02 +00:00
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
2018-08-09 12:42:02 +00:00
$state = _$state_;
$state.params.id = 1;
$httpBackend = _$httpBackend_;
controller = $componentController('vnTicketCard', {$state});
2018-08-09 12:42:02 +00:00
}));
2018-10-03 06:00:19 +00:00
describe('getCard()', () => {
2018-08-09 12:42:02 +00:00
it('should perform a GET query and define the ticket property on controller', () => {
2018-11-15 07:59:22 +00:00
let filter = controller.filter;
2018-08-09 12:42:02 +00:00
filter = encodeURIComponent(JSON.stringify(filter));
2019-01-16 14:38:50 +00:00
$httpBackend.when('GET', `/ticket/api/Tickets/1?filter=${filter}`).respond({id: 1, client: {id: 1}});
2018-08-09 12:42:02 +00:00
$httpBackend.expect('GET', `/ticket/api/Tickets/1?filter=${filter}`);
2019-01-16 14:38:50 +00:00
$httpBackend.when('GET', `/ticket/api/Clients/1/getDebt`).respond();
$httpBackend.expect('GET', `/ticket/api/Clients/1/getDebt`);
2018-10-03 06:00:19 +00:00
controller.getCard();
2018-08-09 12:42:02 +00:00
$httpBackend.flush();
expect(controller.ticket).toBeDefined();
expect(controller.ticket.id).toEqual(1);
});
});
});
});