import './index'; import crudModel from 'core/mocks/crud-model'; describe('Ticket', () => { describe('Component vnTicketDmsIndex', () => { let $componentController; let $scope; let $httpBackend; let controller; beforeEach(angular.mock.module('ticket', $translateProvider => { $translateProvider.translations('en', {}); })); beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { $componentController = _$componentController_; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); controller = $componentController('vnTicketDmsIndex', {$: $scope}); controller.$.model = crudModel; })); describe('deleteDms()', () => { it('should make an HTTP Post query', () => { const dmsId = 1; const dmsIndex = 0; spyOn(controller.vnApp, 'showSuccess'); spyOn(controller.$.model, 'remove'); controller.ticketDms = [{dmsFk: 1}]; controller.dmsIndex = dmsIndex; $httpBackend.when('POST', `/api/ticketDms/${dmsId}/removeFile`).respond({}); $httpBackend.expect('POST', `/api/ticketDms/${dmsId}/removeFile`); controller.deleteDms('ACCEPT'); $httpBackend.flush(); expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); }); });