Skip to content

Commit

Permalink
chore(rating): remove redundant validation and add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imagentleman authored and fernando-sendMail committed Jul 16, 2015
1 parent 01c0d72 commit d1c6f48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/rating/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ angular.module('ui.bootstrap.rating', [])
replace: true,
link: function(scope, element, attrs, ctrls) {
var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];

if ( ngModelCtrl ) {
ratingCtrl.init( ngModelCtrl );
}
ratingCtrl.init( ngModelCtrl );
}
};
});
11 changes: 11 additions & 0 deletions src/rating/test/rating.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ describe('rating directive', function () {
expect($rootScope.rate).toBe(3);
});

it('supports only arrow keys', function() {
$rootScope.rate = undefined;
$rootScope.$digest();

triggerKeyDown(36);
expect($rootScope.rate).toBe(undefined);

triggerKeyDown(41);
expect($rootScope.rate).toBe(undefined);
});

it('can get zero value but not negative', function() {
$rootScope.rate = 1;
$rootScope.$digest();
Expand Down

0 comments on commit d1c6f48

Please sign in to comment.