34 lines
1014 B
JavaScript
34 lines
1014 B
JavaScript
import './index';
|
|
|
|
describe('Ticket', () => {
|
|
describe('Component vnTicketCard', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
let data = {
|
|
id: 1,
|
|
client: {name: 'fooName'}
|
|
};
|
|
let client = {debt: 10.5};
|
|
|
|
beforeEach(ngModule('ticket'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => {
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
let $element = angular.element('<div></div>');
|
|
controller = $componentController('vnTicketCard', {$element});
|
|
|
|
$stateParams.id = data.id;
|
|
$httpBackend.whenRoute('GET', 'Tickets/:id').respond(data);
|
|
$httpBackend.whenRoute('GET', 'Clients/:id/getDebt').respond(client);
|
|
}));
|
|
|
|
it('should request data and set it on the controller', () => {
|
|
controller.reload();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.ticket).toMatchObject(data);
|
|
});
|
|
});
|
|
});
|