import './index.js'; describe('Order', () => { describe('Component vnOrderCard', () => { let controller; let $httpBackend; let data = {id: 1, name: 'fooName'}; let total = 10.5; beforeEach(ngModule('order')); beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); controller = $componentController('vnOrderCard', {$element}); $stateParams.id = data.id; $httpBackend.whenRoute('GET', 'Orders/:id').respond(data); $httpBackend.whenRoute('GET', 'Orders/:id/getTotal').respond(200, total); })); it('should request data and total, merge them, and set it on the controller', () => { controller.reload(); $httpBackend.flush(); expect(controller.order).toEqual(Object.assign({}, data, {total})); }); }); });