diff options
| author | Vojta Jina | 2012-04-10 13:41:51 -0700 | 
|---|---|---|
| committer | Vojta Jina | 2012-04-11 15:50:52 -0700 | 
| commit | 93d62860e988a09fb64e594f50f6cd55a1fc5748 (patch) | |
| tree | 9b8d84fac932993f5ca2f87240b4213dde819416 /test/ng/directive | |
| parent | 5bcd7198664dca2bf85ddf8b3a89f417cd4e4796 (diff) | |
| download | angular.js-93d62860e988a09fb64e594f50f6cd55a1fc5748.tar.bz2 | |
fix(input.radio): support 2-way binding in a repeater
Closes #869
Diffstat (limited to 'test/ng/directive')
| -rw-r--r-- | test/ng/directive/inputSpec.js | 44 | 
1 files changed, 44 insertions, 0 deletions
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( +        '<div ng-repeat="i in items">' + +          '<input type="radio" name="sel_{{i.id}}" ng-model="i.selected" ng-value="true">' + +          '<input type="radio" name="sel_{{i.id}}" ng-model="i.selected" ng-value="false">' + +        '</div>'); + +      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( +        '<div ng-repeat="i in items">' + +          '<input type="radio" ng-model="i.selected" ng-value="true">' + +          '<input type="radio" ng-model="i.selected" ng-value="false">' + +        '</div>'); + +      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); +    });    });  });  | 
