create client onSubmit callback tested
This commit is contained in:
parent
fa64931cc2
commit
62c15fbafa
|
@ -13,25 +13,30 @@ describe('Component vnClientCreate', () => {
|
||||||
$componentController = _$componentController_;
|
$componentController = _$componentController_;
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$state = _$state_;
|
$state = _$state_;
|
||||||
let submit = jasmine.createSpy('submit').and.returnValue(Promise.resolve({data: {id: '1234'}}));
|
$scope.watcher = {
|
||||||
$scope.watcher = {submit};
|
submit: () => {
|
||||||
|
return {
|
||||||
|
then: callback => {
|
||||||
|
callback({data: {id: '1234'}});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should define and set scope, state and client properties', function() {
|
it('should define and set scope, state and client properties', function() {
|
||||||
let controller = $componentController('vnClientCreate', {$scope: $scope, $state: $state});
|
let controller = $componentController('vnClientCreate', {$scope: $scope});
|
||||||
expect(controller.$).toBe($scope);
|
expect(controller.$).toBe($scope);
|
||||||
expect(controller.$state).toBe($state);
|
expect(controller.$state).toBe($state);
|
||||||
expect(controller.client.active).toBe(true);
|
expect(controller.client.active).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
// promise isn't callig go function, needs fixing.
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
// it(`should call submit() on the watcher then expect a callback`, () => {
|
let controller = $componentController('vnClientCreate', {$scope: $scope});
|
||||||
// let controller = $componentController('vnClientCreate', {$scope: $scope});
|
spyOn($state, 'go');
|
||||||
// spyOn($state, 'go');
|
controller.onSubmit();
|
||||||
// controller.onSubmit();
|
expect(controller.$state.go).toHaveBeenCalledWith('clientCard.basicData', {id: '1234'});
|
||||||
// expect(controller.$.watcher.submit).toHaveBeenCalled();
|
});
|
||||||
// expect(controller.$state.go).toHaveBeenCalledWith('clientCard.basicData', {id: '1234'});
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue