import './index'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; describe('Supplier', () => { describe('Component vnSupplierAddressCreate', () => { let $scope; let controller; let $element; beforeEach(ngModule('supplier')); beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $scope.model = crudModel; $scope.watcher = watcher; $element = angular.element(''); controller = $componentController('vnSupplierAgencyTermIndex', {$element, $scope}); })); describe('onSubmit()', () => { it('should make HTTP POST request to save values', () => { jest.spyOn($scope.watcher, 'check'); jest.spyOn($scope.watcher, 'notifySaved'); jest.spyOn($scope.watcher, 'updateOriginalData'); jest.spyOn($scope.model, 'save'); controller.onSubmit(); expect($scope.model.save).toHaveBeenCalledWith(); expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); expect($scope.watcher.check).toHaveBeenCalledWith(); expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); }); }); }); });