2018-05-23 12:26:51 +00:00
|
|
|
import './index';
|
2017-08-31 06:53:17 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
describe('Client', () => {
|
2018-05-24 13:02:38 +00:00
|
|
|
describe('Component vnClientAddressEdit', () => {
|
2017-09-04 13:06:43 +00:00
|
|
|
let $state;
|
2018-08-21 12:13:11 +00:00
|
|
|
let controller;
|
2017-08-31 06:53:17 +00:00
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('client', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
2017-08-31 06:53:17 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, _$state_) => {
|
2017-09-04 13:06:43 +00:00
|
|
|
$state = _$state_;
|
2018-02-06 14:09:31 +00:00
|
|
|
$state.params.addressId = '1';
|
2018-12-22 10:59:26 +00:00
|
|
|
controller = $componentController('vnClientAddressEdit', {$state});
|
2018-08-21 12:13:11 +00:00
|
|
|
controller.$.watcher = {
|
|
|
|
setDirty: () => {},
|
|
|
|
setPristine: () => {},
|
|
|
|
realSubmit: () => {},
|
|
|
|
check: () => {},
|
|
|
|
notifySaved: () => {}
|
|
|
|
};
|
|
|
|
controller.$.model = {
|
|
|
|
remove: () => {},
|
|
|
|
save: () => {}
|
|
|
|
};
|
|
|
|
controller.card = {
|
|
|
|
reload: () => {}
|
|
|
|
};
|
2017-09-04 13:06:43 +00:00
|
|
|
}));
|
2018-08-21 12:13:11 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-10-17 07:28:38 +00:00
|
|
|
describe('cancel()', () => {
|
|
|
|
it('should call goToIndex()', () => {
|
2018-08-21 12:13:11 +00:00
|
|
|
spyOn(controller, 'goToIndex');
|
2018-10-17 07:28:38 +00:00
|
|
|
controller.cancel();
|
2018-08-21 12:13:11 +00:00
|
|
|
|
|
|
|
expect(controller.goToIndex).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('goToIndex()', () => {
|
|
|
|
it('should call $state.go("client.card.address.index")', () => {
|
|
|
|
spyOn(controller.$state, 'go');
|
|
|
|
controller.goToIndex();
|
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('client.card.address.index');
|
2018-08-21 12:13:11 +00:00
|
|
|
});
|
|
|
|
});
|
2017-08-31 06:53:17 +00:00
|
|
|
});
|
|
|
|
});
|