From 31c269400760e6e6d542158c5298823424300372 Mon Sep 17 00:00:00 2001 From: imagentleman Date: Sun, 29 Mar 2015 11:51:39 -0500 Subject: [PATCH] chore(rating): remove redundant validation and add unit tests Closes #3464 --- src/rating/rating.js | 5 +---- src/rating/test/rating.spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/rating/rating.js b/src/rating/rating.js index 1ff9ebd6f4..86327c87a3 100644 --- a/src/rating/rating.js +++ b/src/rating/rating.js @@ -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 ); } }; }); \ No newline at end of file diff --git a/src/rating/test/rating.spec.js b/src/rating/test/rating.spec.js index 0a32707ffa..038bdd4f39 100644 --- a/src/rating/test/rating.spec.js +++ b/src/rating/test/rating.spec.js @@ -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();