Skip to content

Commit 31c2694

Browse files
imagentlemanwesleycho
authored andcommitted
chore(rating): remove redundant validation and add unit tests
Closes angular-ui#3464
1 parent 2c1a4cc commit 31c2694

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/rating/rating.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ angular.module('ui.bootstrap.rating', [])
8181
replace: true,
8282
link: function(scope, element, attrs, ctrls) {
8383
var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];
84-
85-
if ( ngModelCtrl ) {
86-
ratingCtrl.init( ngModelCtrl );
87-
}
84+
ratingCtrl.init( ngModelCtrl );
8885
}
8986
};
9087
});

src/rating/test/rating.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ describe('rating directive', function () {
165165
expect($rootScope.rate).toBe(3);
166166
});
167167

168+
it('supports only arrow keys', function() {
169+
$rootScope.rate = undefined;
170+
$rootScope.$digest();
171+
172+
triggerKeyDown(36);
173+
expect($rootScope.rate).toBe(undefined);
174+
175+
triggerKeyDown(41);
176+
expect($rootScope.rate).toBe(undefined);
177+
});
178+
168179
it('can get zero value but not negative', function() {
169180
$rootScope.rate = 1;
170181
$rootScope.$digest();

0 commit comments

Comments
 (0)