Specific tests for on() with a matching selector
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/7e9055b1 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/7e9055b1 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/7e9055b1 Branch: refs/heads/5.4-js-rewrite Commit: 7e9055b1ed8e998df99b8d9f6c410af55bfb4df7 Parents: 553e39d Author: Howard M. Lewis Ship <[email protected]> Authored: Mon Aug 13 08:59:27 2012 -0700 Committer: Howard M. Lewis Ship <[email protected]> Committed: Mon Aug 13 08:59:27 2012 -0700 ---------------------------------------------------------------------- tapestry-core/src/test/app1/JavaScriptTests.tml | 20 ++++-------- .../integration/app1/pages/test-spi.coffee | 25 +++++++++++++-- 2 files changed, 29 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e9055b1/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 119b19b..48c6d25 100644 --- a/tapestry-core/src/test/app1/JavaScriptTests.tml +++ b/tapestry-core/src/test/app1/JavaScriptTests.tml @@ -2,26 +2,20 @@ <head><title>JavaScript Tests</title></head> <body> -<div id="qunit"/> +<h1> + <t:pagelink page="index">back to index</t:pagelink> +</h1> -<ul> - <li> - <t:pagelink page="javascripttests">rerun all tests</t:pagelink> - </li> - <li> - <t:pagelink page="index">back to index</t:pagelink> - </li> -</ul> +<div id="qunit"/> <!-- The rest are test elements for the core/spi tests, etc. --> <hr/> -<div id="spi-test1"/> - -<div id="spi-test2"> - <a href="#">button</a> +<div id="spi-eventelement"> + <a href="#" class="btn btn-primary">primary</a> + <a href="#" class="btn" data-use="secondary">secondary</a> </div> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e9055b1/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 d0f3736..4659df6 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 @@ -2,7 +2,7 @@ require ["core/spi"], (spi) -> module "core/spi" test "get wrapped element by id", -> - e = spi.wrap "spi-test1" + e = spi.wrap "spi-eventelement" ok e isnt null, "element found and wrapped" @@ -14,7 +14,7 @@ require ["core/spi"], (spi) -> test "pause and resume events", -> clicks = 0 - container = spi.wrap "spi-test2" + container = spi.wrap "spi-eventelement" button = container.find "a" # Remember that Prototype will never trigger a native event, just a @@ -37,4 +37,23 @@ require ["core/spi"], (spi) -> button.trigger "x:click" - equal clicks, 2, "notifications resume after EventHandler started" \ No newline at end of file + equal clicks, 2, "notifications resume after EventHandler started" + + test "selector used with events filters", -> + + clicks = 0 + container = spi.wrap "spi-eventelement" + primary = container.find "a.btn-primary" + secondary = container.find "a[data-use=secondary]" + + container.on "x:click", "a.btn-primary", (event) -> + event.stop() + clicks++ + + primary.trigger "x:click" + + equal clicks, 1, "click on selected element invokes handler" + + secondary.trigger "x:click" + + equal clicks, 1, "click on non-selected element does not invoke handler" \ No newline at end of file
