2018-05-23 12:26:51 +00:00
|
|
|
import './index';
|
2017-08-31 17:15:17 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientCreate', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
|
|
|
let $state;
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2017-08-31 17:15:17 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2017-08-31 17:15:17 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$state = _$state_;
|
|
|
|
$scope.watcher = {
|
|
|
|
submit: () => {
|
|
|
|
return {
|
|
|
|
then: callback => {
|
|
|
|
callback({data: {id: '1234'}});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
2017-10-17 12:24:40 +00:00
|
|
|
controller = $componentController('vnClientCreate', {$scope: $scope});
|
2017-09-04 13:06:43 +00:00
|
|
|
}));
|
2017-08-31 17:15:17 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
it('should define and set scope, state and client properties', () => {
|
|
|
|
expect(controller.$).toBe($scope);
|
|
|
|
expect(controller.$state).toBe($state);
|
|
|
|
expect(controller.client.active).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
|
|
|
spyOn($state, 'go');
|
|
|
|
controller.onSubmit();
|
2017-09-20 12:01:33 +00:00
|
|
|
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('client.card.basicData', {id: '1234'});
|
2017-09-04 13:06:43 +00:00
|
|
|
});
|
2017-09-04 10:46:19 +00:00
|
|
|
});
|
2017-08-31 17:15:17 +00:00
|
|
|
});
|
|
|
|
});
|