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 workerDmsId = 1; const dmsIndex = 0; jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.$.model, 'remove'); controller.workerDms = [{id: 1, dmsFk: 4}]; controller.dmsIndex = dmsIndex; $httpBackend.when('POST', `WorkerDms/${workerDmsId}/removeFile`).respond({}); $httpBackend.expect('POST', `WorkerDms/${workerDmsId}/removeFile`); controller.deleteDms('accept'); $httpBackend.flush(); expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); }); });