aboutsummaryrefslogtreecommitdiffstats
path: root/test/directive/inputSpec.js
diff options
context:
space:
mode:
authorVojta Jina2012-03-23 13:04:52 -0700
committerVojta Jina2012-03-26 21:14:09 -0700
commit09e175f02cca0f4a295fd0c9b980cd8f432e722b (patch)
tree49796ba88d2db7a6e621155e9849109206f744cd /test/directive/inputSpec.js
parent5c5b1183c82a28841b3e1e246ee341262e91d743 (diff)
downloadangular.js-09e175f02cca0f4a295fd0c9b980cd8f432e722b.tar.bz2
feat(ngValue): allow radio inputs to have non string values
Closes #816
Diffstat (limited to 'test/directive/inputSpec.js')
-rw-r--r--test/directive/inputSpec.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/directive/inputSpec.js b/test/directive/inputSpec.js
index 0b848df1..8d0e44b3 100644
--- a/test/directive/inputSpec.js
+++ b/test/directive/inputSpec.js
@@ -1078,4 +1078,42 @@ describe('input', function() {
expect(scope.value).toBe('value3');
}));
});
+
+
+ describe('ng-value', function() {
+
+ it('should evaluate and set constant expressions', function() {
+ compileInput('<input type="radio" ng-model="selected" ng-value="true">' +
+ '<input type="radio" ng-model="selected" ng-value="false">' +
+ '<input type="radio" ng-model="selected" ng-value="1">');
+ scope.$digest();
+
+ browserTrigger(inputElm[0], 'click');
+ expect(scope.selected).toBe(true);
+
+ browserTrigger(inputElm[1], 'click');
+ expect(scope.selected).toBe(false);
+
+ browserTrigger(inputElm[2], 'click');
+ expect(scope.selected).toBe(1);
+ });
+
+
+ it('should watch the expression', function() {
+ compileInput('<input type="radio" ng-model="selected" ng-value="value">');
+
+ scope.$apply(function() {
+ scope.selected = scope.value = {some: 'object'};
+ });
+ expect(inputElm[0].checked).toBe(true);
+
+ scope.$apply(function() {
+ scope.value = {some: 'other'};
+ });
+ expect(inputElm[0].checked).toBe(false);
+
+ browserTrigger(inputElm, 'click');
+ expect(scope.selected).toBe(scope.value);
+ });
+ });
});