import './index'; describe('Supplier', () => { describe('Component vnNewBankentity', () => { let controller; let $httpBackend; let $scope; beforeEach(ngModule('supplier')); beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); controller = $componentController('vnNewBankentity', {$element, $scope}); controller.client = {id: 101}; })); describe('onAccept()', () => { it('should perform a POST query and show a success snackbar', () => { let params = {countryFk: 1}; controller.location = {countryFk: 1}; jest.spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('PATCH', `bankentity`, params).respond(200, params); controller.onAccept(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The bankentity has been created. You can save the data now'); }); }); }); });