import './index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; describe('InvoiceIn', () => { describe('Component due day', () => { let controller; let $scope; let vnApp; beforeEach(ngModule('invoiceIn')); beforeEach(inject(($componentController, $rootScope, _vnApp_) => { vnApp = _vnApp_; jest.spyOn(vnApp, 'showError'); $scope = $rootScope.$new(); $scope.model = crudModel; $scope.watcher = watcher; const $element = angular.element(''); controller = $componentController('vnInvoiceInDueDay', {$element, $scope}); controller.invoiceIn = {id: 1}; })); describe('onSubmit()', () => { it('should make HTTP POST request to save due day values', () => { controller.card = {reload: () => {}}; jest.spyOn($scope.watcher, 'check'); jest.spyOn($scope.watcher, 'notifySaved'); jest.spyOn($scope.watcher, 'updateOriginalData'); jest.spyOn(controller.card, 'reload'); 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(); expect(controller.card.reload).toHaveBeenCalledWith(); }); }); }); });