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

34 lines
1001 B
JavaScript
Raw Permalink Normal View History

2018-08-09 12:42:02 +00:00
import './index';
describe('Ticket', () => {
describe('Component vnTicketCard', () => {
let controller;
let $httpBackend;
2019-11-10 10:08:44 +00:00
let data = {
id: 1,
client: {name: 'fooName'}
};
let client = {debt: 10.5};
2018-08-09 12:42:02 +00:00
beforeEach(ngModule('ticket'));
2018-08-09 12:42:02 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => {
2018-08-09 12:42:02 +00:00
$httpBackend = _$httpBackend_;
2019-11-10 10:08:44 +00:00
let $element = angular.element('<div></div>');
controller = $componentController('vnTicketCard', {$element});
2018-08-09 12:42:02 +00:00
2019-11-10 10:08:44 +00:00
$stateParams.id = data.id;
$httpBackend.whenRoute('GET', 'Tickets/:id').respond(data);
$httpBackend.whenRoute('GET', 'Clients/:id/getDebt').respond(client);
}));
2018-08-09 12:42:02 +00:00
2019-11-10 10:08:44 +00:00
it('should request data and set it on the controller', () => {
controller.reload();
$httpBackend.flush();
2018-08-09 12:42:02 +00:00
2019-11-10 10:08:44 +00:00
expect(controller.ticket).toMatchObject(data);
2018-08-09 12:42:02 +00:00
});
});
});