import './index'; import crudModel from 'core/mocks/crud-model'; describe('Worker', () => { describe('Component vnWorkerDmsIndex', () => { let $componentController; let $scope; let $element; let $httpBackend; let controller; beforeEach(ngModule('worker')); beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { $componentController = _$componentController_; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $element = angular.element(` { it('should make an HTTP Post query', () => { const dmsId = 4; const dmsIndex = 0; jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.$.model, 'remove'); controller.workerDms = [{dmsFk: 4}]; controller.dmsIndex = dmsIndex; $httpBackend.when('POST', `WorkerDms/${dmsId}/removeFile`).respond({}); $httpBackend.expect('POST', `WorkerDms/${dmsId}/removeFile`); controller.deleteDms('accept'); $httpBackend.flush(); expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); }); });