diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/directive/formSpec.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/test/ng/directive/formSpec.js b/test/ng/directive/formSpec.js index b3673264..fb64fdb3 100644 --- a/test/ng/directive/formSpec.js +++ b/test/ng/directive/formSpec.js @@ -83,10 +83,11 @@ describe('form', function() { }); - it('should allow form name to be an expression', function() { + it('should support expression in form name', function() { doc = $compile('<form name="obj.myForm"></form>')(scope); - expect(scope['obj.myForm']).toBeTruthy(); + expect(scope.obj).toBeDefined(); + expect(scope.obj.myForm).toBeTruthy(); }); @@ -325,6 +326,30 @@ describe('form', function() { }); + it('should deregister a child form whose name is an expression when its DOM is removed', function() { + doc = jqLite( + '<form name="parent">' + + '<div class="ng-form" name="child.form">' + + '<input ng:model="modelA" name="inputA" required>' + + '</div>' + + '</form>'); + $compile(doc)(scope); + scope.$apply(); + + var parent = scope.parent, + child = scope.child.form; + + expect(parent).toBeDefined(); + expect(child).toBeDefined(); + expect(parent.$error.required).toEqual([child]); + doc.children().remove(); //remove child + + expect(parent.child).toBeUndefined(); + expect(scope.child.form).toBeUndefined(); + expect(parent.$error.required).toBe(false); + }); + + it('should deregister a input when its removed from DOM', function() { doc = jqLite( '<form name="parent">' + |
