salix/modules/client/front/address/edit/index.spec.js

60 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-05-23 12:26:51 +00:00
import './index';
describe('Client', () => {
describe('Component vnClientAddressEdit', () => {
let $state;
let controller;
beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, _$state_) => {
$state = _$state_;
2018-02-06 14:09:31 +00:00
$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');
});
});
});
});