aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2010-02-04 13:27:56 -0800
committerMisko Hevery2010-02-04 13:27:56 -0800
commit1da18e73a4d09b2a1ace92a4094eeba014eb7dc4 (patch)
tree5f679ca5b575f29cd5938099a5dab37aa968c85f /test
parent5dd43b85e73ca1708e7fd85094b533b02266a79a (diff)
downloadangular.js-1da18e73a4d09b2a1ace92a4094eeba014eb7dc4.tar.bz2
consider widget errors only when widgets are visible
Diffstat (limited to 'test')
-rw-r--r--test/BinderTest.js11
-rw-r--r--test/FormattersTest.js7
-rw-r--r--test/testabilityPatch.js12
3 files changed, 26 insertions, 4 deletions
diff --git a/test/BinderTest.js b/test/BinderTest.js
index a45183a4..41319b52 100644
--- a/test/BinderTest.js
+++ b/test/BinderTest.js
@@ -788,6 +788,17 @@ BinderTest.prototype.testValidateForm = function() {
assertEquals(0, c.scope.get("$invalidWidgets.length"));
};
+BinderTest.prototype.testValidateOnlyVisibleItems = function(){
+ var c = compile('<input name="name" ng-required><input ng-show="show" name="name" ng-required>');
+ c.scope.set("show", true);
+ c.binder.updateView();
+ assertEquals(2, c.scope.get("$invalidWidgets.length"));
+
+ c.scope.set("show", false);
+ c.binder.updateView();
+ assertEquals(1, c.scope.get("$invalidWidgets.length"));
+};
+
BinderTest.prototype.testDeleteAttributeIfEvaluatesFalse = function() {
var c = compile(
'<input name="a0" ng-bind-attr="{disabled:\'{{true}}\'}"><input name="a1" ng-bind-attr="{disabled:\'{{false}}\'}">' +
diff --git a/test/FormattersTest.js b/test/FormattersTest.js
index e91fd37f..59f12c1f 100644
--- a/test/FormattersTest.js
+++ b/test/FormattersTest.js
@@ -25,6 +25,13 @@ TestCase("formatterTest", {
testNumber: function() {
assertEquals('1', angular.formatter.number.format(1));
assertEquals(1, angular.formatter.number.format('1'));
+ },
+
+ testTrim: function() {
+ assertEquals('', angular.formatter.trim.format(null));
+ assertEquals('', angular.formatter.trim.format(""));
+ assertEquals('a', angular.formatter.trim.format(" a "));
+ assertEquals('a', angular.formatter.trim.parse(' a '));
}
});
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index 44199b66..cb1432f7 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -96,15 +96,19 @@ function decode64(base64){
configureJQueryPlugins();
+function isVisible(node) {
+ var display = $(node).css('display');
+ if (display == 'block') display = "";
+ return display != 'none';
+}
+
function assertHidden(node) {
var display = node.css('display');
- assertEquals("Node should be hidden but vas visible: " + node.sortedHtml(), 'none', display);
+ assertFalse("Node should be hidden but vas visible: " + node.sortedHtml(), isVisible(node));
}
function assertVisible(node) {
- var display = node.css('display');
- if (display == 'block') display = "";
- assertEquals("Node should be visible but vas hidden: " + node.sortedHtml(), '', display);
+ assertTrue("Node should be visible but vas hidden: " + node.sortedHtml(), isVisible(node));
}
function assertJsonEquals(expected, actual) {