This commit is contained in:
Vicente Falco 2017-09-04 13:36:14 +02:00
commit 0c8f9f2b11
1 changed files with 16 additions and 11 deletions

View File

@ -13,25 +13,30 @@ describe('Component vnClientCreate', () => {
$componentController = _$componentController_;
$scope = $rootScope.$new();
$state = _$state_;
let submit = jasmine.createSpy('submit').and.returnValue(Promise.resolve({data: {id: '1234'}}));
$scope.watcher = {submit};
$scope.watcher = {
submit: () => {
return {
then: callback => {
callback({data: {id: '1234'}});
}
};
}
};
}));
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.$state).toBe($state);
expect(controller.client.active).toBe(true);
});
describe('onSubmit()', () => {
// promise isn't callig go function, needs fixing.
// it(`should call submit() on the watcher then expect a callback`, () => {
// let controller = $componentController('vnClientCreate', {$scope: $scope});
// spyOn($state, 'go');
// controller.onSubmit();
// expect(controller.$.watcher.submit).toHaveBeenCalled();
// expect(controller.$state.go).toHaveBeenCalledWith('clientCard.basicData', {id: '1234'});
// });
it(`should call submit() on the watcher then expect a callback`, () => {
let controller = $componentController('vnClientCreate', {$scope: $scope});
spyOn($state, 'go');
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('clientCard.basicData', {id: '1234'});
});
});
});