import './index'; describe('Client', () => { describe('Component vnClientAddressEdit', () => { let $state; let controller; beforeEach(angular.mock.module('client', $translateProvider => { $translateProvider.translations('en', {}); })); beforeEach(angular.mock.inject(($componentController, _$state_) => { $state = _$state_; $state.params.addressId = '1'; controller = $componentController('vnClientAddressEdit', {$state}); controller.$.watcher = { setDirty: () => {}, setPristine: () => {}, realSubmit: () => {}, check: () => {}, notifySaved: () => {} }; controller.$.model = { remove: () => {}, save: () => {} }; controller.card = { reload: () => {} }; })); describe('removeObservation()', () => { it('should call $.watcher.setDirty() and $.model.remove(index)', () => { spyOn(controller.$.watcher, 'setDirty'); spyOn(controller.$.model, 'remove'); controller.removeObservation(1); expect(controller.$.model.remove).toHaveBeenCalledWith(1); expect(controller.$.watcher.setDirty).toHaveBeenCalledWith(); }); }); describe('cancel()', () => { it('should call goToIndex()', () => { spyOn(controller, 'goToIndex'); controller.cancel(); expect(controller.goToIndex).toHaveBeenCalledWith(); }); }); describe('goToIndex()', () => { it('should call $state.go("client.card.address.index")', () => { spyOn(controller.$state, 'go'); controller.goToIndex(); expect(controller.$state.go).toHaveBeenCalledWith('client.card.address.index'); }); }); }); });