From 09e175f02cca0f4a295fd0c9b980cd8f432e722b Mon Sep 17 00:00:00 2001
From: Vojta Jina
Date: Fri, 23 Mar 2012 13:04:52 -0700
Subject: feat(ngValue): allow radio inputs to have non string values
Closes #816
---
test/directive/inputSpec.js | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
(limited to 'test/directive')
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('' +
+ '' +
+ '');
+ 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('');
+
+ 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);
+ });
+ });
});
--
cgit v1.2.3