import './index.js'; import crudModel from 'core/mocks/crud-model'; describe('InvoiceOut', () => { describe('Component summary', () => { let controller; let $httpBackend; let $scope; beforeEach(ngModule('invoiceOut')); beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element('<vn-invoice-out-summary></vn-invoice-out-summary>'); controller = $componentController('vnInvoiceOutSummary', {$element, $scope}); controller._invoiceOut = {id: 1}; controller.$.ticketsModel = crudModel; })); describe('loadData()', () => { it('should perform a query to set summary', () => { $httpBackend.expect('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for'); controller.loadData(); $httpBackend.flush(); expect(controller.summary).toEqual('the data you are looking for'); }); }); }); });