From 4f78fd692c0ec51241476e6be9a4df06cd62fdd6 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Thu, 8 Sep 2011 13:56:29 -0700
Subject: feat(forms): new and improved forms
---
test/BinderSpec.js | 135 ++++++-----------------------------------------------
1 file changed, 14 insertions(+), 121 deletions(-)
(limited to 'test/BinderSpec.js')
diff --git a/test/BinderSpec.js b/test/BinderSpec.js
index 224c449f..fa7fde60 100644
--- a/test/BinderSpec.js
+++ b/test/BinderSpec.js
@@ -28,56 +28,12 @@ describe('Binder', function(){
}
});
-
- it('text-field should default to value attribute', function(){
- var scope = this.compile('');
- scope.$apply();
- assertEquals('abc', scope.model.price);
- });
-
- it('ChangingTextareaUpdatesModel', function(){
- var scope = this.compile('');
- scope.$apply();
- assertEquals(scope.model.note, 'abc');
- });
-
- it('ChangingRadioUpdatesModel', function(){
- var scope = this.compile('
');
assertEquals(scope.a, 123);
@@ -236,14 +192,13 @@ describe('Binder', function(){
});
it('RepeaterAdd', function(){
- var scope = this.compile('
');
+ var scope = this.compile('
');
scope.items = [{x:'a'}, {x:'b'}];
scope.$apply();
var first = childNode(scope.$element, 1);
var second = childNode(scope.$element, 2);
expect(first.val()).toEqual('a');
expect(second.val()).toEqual('b');
- return
first.val('ABC');
browserTrigger(first, 'keydown');
@@ -440,15 +395,6 @@ describe('Binder', function(){
assertEquals('123{{a}}{{b}}{{c}}', scope.$element.text());
});
- it('RepeaterShouldBindInputsDefaults', function () {
- var scope = this.compile('
');
- scope.items = [{}, {name:'misko'}];
- scope.$apply();
-
- expect(scope.$eval('items[0].name')).toEqual("123");
- expect(scope.$eval('items[1].name')).toEqual("misko");
- });
-
it('ShouldTemplateBindPreElements', function () {
var scope = this.compile('
Hello {{name}}!');
scope.name = "World";
@@ -459,7 +405,11 @@ describe('Binder', function(){
it('FillInOptionValueWhenMissing', function(){
var scope = this.compile(
- '
');
+ '
');
scope.a = 'A';
scope.b = 'B';
scope.$apply();
@@ -477,52 +427,14 @@ describe('Binder', function(){
expect(optionC.text()).toEqual('C');
});
- it('ValidateForm', function(){
- var scope = this.compile('
' +
- '
',
- jqLite(document.body));
- var items = [{}, {}];
- scope.items = items;
- scope.$apply();
- assertEquals(3, scope.$service('$invalidWidgets').length);
-
- scope.name = '';
- scope.$apply();
- assertEquals(3, scope.$service('$invalidWidgets').length);
-
- scope.name = ' ';
- scope.$apply();
- assertEquals(3, scope.$service('$invalidWidgets').length);
-
- scope.name = 'abc';
- scope.$apply();
- assertEquals(2, scope.$service('$invalidWidgets').length);
-
- items[0].name = 'abc';
- scope.$apply();
- assertEquals(1, scope.$service('$invalidWidgets').length);
-
- items[1].name = 'abc';
- scope.$apply();
- assertEquals(0, scope.$service('$invalidWidgets').length);
- });
-
- it('ValidateOnlyVisibleItems', function(){
- var scope = this.compile('
', jqLite(document.body));
- scope.show = true;
- scope.$apply();
- assertEquals(2, scope.$service('$invalidWidgets').length);
-
- scope.show = false;
- scope.$apply();
- assertEquals(1, scope.$service('$invalidWidgets').visible());
- });
-
it('DeleteAttributeIfEvaluatesFalse', function(){
var scope = this.compile('
' +
- '' +
- '' +
- '
');
+ '
' +
+ '
' +
+ '
' +
+ '
' +
+ '
' +
+ '
');
scope.$apply();
function assertChild(index, disabled) {
var child = childNode(scope.$element, index);
@@ -556,8 +468,8 @@ describe('Binder', function(){
it('ItShouldSelectTheCorrectRadioBox', function(){
var scope = this.compile('