You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/08/13 20:47:05 UTC

[7/9] git commit: Add tests for ElementWrapper.visible(), .show(), .hide()

Add tests for ElementWrapper.visible(), .show(), .hide()


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/4ea77f4e
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/4ea77f4e
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/4ea77f4e

Branch: refs/heads/5.4-js-rewrite
Commit: 4ea77f4e22c42a81916f0dd68ef564cc5fe42095
Parents: f705143
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Aug 13 09:10:50 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Aug 13 09:10:50 2012 -0700

----------------------------------------------------------------------
 tapestry-core/src/test/app1/JavaScriptTests.tml    |    4 ++
 .../integration/app1/pages/test-spi.coffee         |   28 ++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4ea77f4e/tapestry-core/src/test/app1/JavaScriptTests.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/JavaScriptTests.tml b/tapestry-core/src/test/app1/JavaScriptTests.tml
index 48c6d25..8b25838 100644
--- a/tapestry-core/src/test/app1/JavaScriptTests.tml
+++ b/tapestry-core/src/test/app1/JavaScriptTests.tml
@@ -18,6 +18,10 @@
     <a href="#" class="btn" data-use="secondary">secondary</a>
 </div>
 
+<div id="spi-visibility">
+    <span>initially visible</span>
+</div>
+
 
 </body>
 </html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4ea77f4e/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-spi.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-spi.coffee b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-spi.coffee
index 4659df6..08f530c 100644
--- a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-spi.coffee
+++ b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-spi.coffee
@@ -56,4 +56,30 @@ require ["core/spi"], (spi) ->
 
     secondary.trigger "x:click"
 
-    equal clicks, 1, "click on non-selected element does not invoke handler"
\ No newline at end of file
+    equal clicks, 1, "click on non-selected element does not invoke handler"
+
+  test "this is matched element in handler", ->
+
+    container = spi.wrap "spi-eventelement"
+    primary = container.find "a.btn-primary"
+
+    container.on "x:click", "a.btn-primary", (event) ->
+      event.stop()
+
+      strictEqual this, primary.element, "this should be the element that was matched"
+
+    primary.trigger "x:click"
+
+  test "visibility, hide(), and show()", ->
+
+    e = (spi.wrap "spi-visibility").find "span"
+
+    equal e.visible(), true, "element is initially visible"
+
+    e.hide()
+
+    equal e.visible(), false, "element is not visible once hidden"
+
+    e.show()
+
+    equal e.visible(), true, "element is visible against once shown"