aboutsummaryrefslogtreecommitdiffstats
path: root/test/directive/formSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2012-03-15 14:08:49 -0700
committerMisko Hevery2012-03-19 11:35:09 -0700
commit823adb231995e917bc060bfa49453e2a96bac2b6 (patch)
tree618aefaaac1c1bc9a4aa46f890c6bd43feab5b01 /test/directive/formSpec.js
parent21e74c2d2e8e985b23711785287feb59965cbd90 (diff)
downloadangular.js-823adb231995e917bc060bfa49453e2a96bac2b6.tar.bz2
fix(ngForm): alias name||ngForm
form directive was requiring name attribute even when invoked as attribute, resulting in unnecessary duplication
Diffstat (limited to 'test/directive/formSpec.js')
-rw-r--r--test/directive/formSpec.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/directive/formSpec.js b/test/directive/formSpec.js
index ec16e19b..5c34b5ad 100644
--- a/test/directive/formSpec.js
+++ b/test/directive/formSpec.js
@@ -33,9 +33,9 @@ describe('form', function() {
it('should remove the widget when element removed', function() {
doc = $compile(
- '<form name="myForm">' +
- '<input type="text" name="alias" ng-model="value" store-model-ctrl/>' +
- '</form>')(scope);
+ '<form name="myForm">' +
+ '<input type="text" name="alias" ng-model="value" store-model-ctrl/>' +
+ '</form>')(scope);
var form = scope.myForm;
control.$setValidity('required', false);
@@ -48,6 +48,17 @@ describe('form', function() {
});
+ it('should use ng-form as form name', function() {
+ doc = $compile(
+ '<div ng-form="myForm">' +
+ '<input type="text" name="alias" ng-model="value"/>' +
+ '</div>')(scope);
+
+ expect(scope.myForm).toBeDefined();
+ expect(scope.myForm.alias).toBeDefined();
+ });
+
+
it('should prevent form submission', function() {
var startingUrl = '' + window.location;
doc = jqLite('<form name="myForm"><input type="submit" value="submit" />');
@@ -89,8 +100,7 @@ describe('form', function() {
it('should allow form name to be an expression', function() {
doc = $compile('<form name="obj.myForm"></form>')(scope);
- expect(scope.obj).toBeDefined();
- expect(scope.obj.myForm).toBeTruthy();
+ expect(scope['obj.myForm']).toBeTruthy();
});