From 93d62860e988a09fb64e594f50f6cd55a1fc5748 Mon Sep 17 00:00:00 2001
From: Vojta Jina
Date: Tue, 10 Apr 2012 13:41:51 -0700
Subject: fix(input.radio): support 2-way binding in a repeater
Closes #869
---
test/ng/directive/inputSpec.js | 44 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
(limited to 'test/ng')
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index 9f8b21c4..6cecf125 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -1106,5 +1106,49 @@ describe('input', function() {
browserTrigger(inputElm.eq(1), 'click');
expect(scope.selected).toBe(2);
});
+
+
+ it('should work inside ngRepeat with primitive values', function() {
+ compileInput(
+ '
' +
+ '' +
+ '' +
+ '
');
+
+ scope.$apply(function() {
+ scope.items = [{id: 1, selected: true}, {id: 2, selected: false}];
+ });
+
+ inputElm = formElm.find('input');
+ expect(inputElm[0].checked).toBe(true);
+ expect(inputElm[1].checked).toBe(false);
+ expect(inputElm[2].checked).toBe(false);
+ expect(inputElm[3].checked).toBe(true);
+
+ browserTrigger(inputElm.eq(1), 'click');
+ expect(scope.items[0].selected).toBe(false);
+ });
+
+
+ it('should work inside ngRepeat without name attribute', function() {
+ compileInput(
+ '' +
+ '' +
+ '' +
+ '
');
+
+ scope.$apply(function() {
+ scope.items = [{id: 1, selected: true}, {id: 2, selected: false}];
+ });
+
+ inputElm = formElm.find('input');
+ expect(inputElm[0].checked).toBe(true);
+ expect(inputElm[1].checked).toBe(false);
+ expect(inputElm[2].checked).toBe(false);
+ expect(inputElm[3].checked).toBe(true);
+
+ browserTrigger(inputElm.eq(1), 'click');
+ expect(scope.items[0].selected).toBe(false);
+ });
});
});
--
cgit v1.2.3