import './index'; import crudModel from 'core/mocks/crud-model'; describe('Client', () => { describe('Component vnClientDmsIndex', () => { let $scope; let $httpBackend; let controller; beforeEach(ngModule('client')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); controller = $componentController('vnClientDmsIndex', {$element: null, $scope}); controller.$.model = crudModel; })); describe('deleteDms()', () => { it('should make an HTTP Post query', () => { jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.$.model, 'remove'); const dmsId = 1; const dmsIndex = 0; controller.clientDms = [{dmsFk: 1}]; $httpBackend.expectPOST(`ClientDms/${dmsId}/removeFile`).respond(); controller.deleteDms(dmsIndex); $httpBackend.flush(); expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); }); });