import './index.js'; describe('Order Component vnOrderDescriptor', () => { let $httpBackend; let controller; const order = {id: 1}; beforeEach(ngModule('order')); beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; controller = $componentController('vnOrderDescriptor', {$element: null}, {order}); })); describe('deleteOrder()', () => { it(`should perform a DELETE query`, () => { jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.$state, 'go'); $httpBackend.expectDELETE(`Orders/${order.id}`).respond(); controller.deleteOrder(); $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$state.go).toHaveBeenCalledWith('order.index'); }); }); });