Rework CDI InjectionPage test to use Promise pipes

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e1e7a7e2
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e1e7a7e2
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e1e7a7e2

Branch: refs/heads/master
Commit: e1e7a7e2eb2804df2346d26120b834d96034740e
Parents: a567813
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Tue Jun 18 09:55:06 2013 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Tue Jun 18 09:55:06 2013 +0200

----------------------------------------------------------------------
 .../main/webapp/js-test/tests/cdi/injection.js  | 32 ++++++++++++--------
 1 file changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e1e7a7e2/wicket-examples/src/main/webapp/js-test/tests/cdi/injection.js
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/webapp/js-test/tests/cdi/injection.js 
b/wicket-examples/src/main/webapp/js-test/tests/cdi/injection.js
index 9e55d7e..fc0f611 100644
--- a/wicket-examples/src/main/webapp/js-test/tests/cdi/injection.js
+++ b/wicket-examples/src/main/webapp/js-test/tests/cdi/injection.js
@@ -18,31 +18,39 @@
 $q(document).ready(function() {
        "use strict";
 
+       var countSelector = 'p > span';
+
+       var increment = function($) {
+               return gym.click($('a:contains("increment")'));
+       };
+
        module('CDI');
 
        asyncTest('injection', function () {
                expect(2);
 
+               var initialValue;
+
                gym.load('/cdi/injection').then(function($) {
 
-                       var initialValue = $('p > span').text();
+                       initialValue = $(countSelector).text();
                        initialValue = parseInt(initialValue, 10);
 
-                       gym.click($('p > a')).then(function($$) {
+                       return increment($);
+               }).then(function($) {
 
-                               var counterLabelValue = $$('p > span').text();
-                               var expectedValue = initialValue + 1;
-                               equal(counterLabelValue, "" + expectedValue, 
'The new value of the counter is +1');
+                       var counterLabelValue = $(countSelector).text();
+                       var expectedValue = initialValue + 1;
+                       equal(counterLabelValue, "" + expectedValue, 'The new 
value of the counter is +1');
 
-                               gym.click($$('p > a')).then(function($$$) {
+                       return increment($);
+               }).then(function($) {
 
-                                       counterLabelValue = $$$('p > 
span').text();
-                                       expectedValue = initialValue + 2;
-                                       equal(counterLabelValue, "" + 
expectedValue, 'The new value of the counter is +2');
+                       var counterLabelValue = $(countSelector).text();
+                       var expectedValue = initialValue + 2;
+                       equal(counterLabelValue, "" + expectedValue, 'The new 
value of the counter is +2');
 
-                                       start();
-                               });
-                       });
+                       start();
                });
        });
 

Reply via email to