From 1da18e73a4d09b2a1ace92a4094eeba014eb7dc4 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 4 Feb 2010 13:27:56 -0800 Subject: consider widget errors only when widgets are visible --- test/BinderTest.js | 11 +++++++++++ test/FormattersTest.js | 7 +++++++ test/testabilityPatch.js | 12 ++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'test') 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(''); + 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( '' + 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) { -- cgit v1.2.3