From 675978f41fbd05a7ed3481a79b772877a59a1c15 Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Fri, 13 Aug 2010 12:05:50 -0700 Subject: Provide all jquery functions as futures --- src/scenario/DSL.js | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js index a64f8548..a533a5c3 100644 --- a/src/scenario/DSL.js +++ b/src/scenario/DSL.js @@ -102,18 +102,30 @@ angular.scenario.dsl.repeater = function(selector) { }; angular.scenario.dsl.element = function(selector) { - var nameSuffix = "element '" + selector + "'"; - return $scenario.addFuture('Find ' + nameSuffix, function(done) { - var self = this, repeaterArray = [], ngBindPattern; - var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN); - if (startIndex >= 0) { - ngBindPattern = selector.substring(startIndex + 2, selector.length - 2); - var element = this.testDocument.find('*').filter(function() { - return self.jQuery(this).attr('ng:bind') == ngBindPattern; - }); - done(element); - } else { - done(this.testDocument.find(selector)); - } - }); + var namePrefix = "Element '" + selector + "'"; + var futureJquery = {}; + for (key in _jQuery.fn) { + (function(){ + var jqFnName = key; + var jqFn = _jQuery.fn[key]; + futureJquery[key] = function() { + var jqArgs = arguments; + return $scenario.addFuture(namePrefix + "." + jqFnName + "()", + function(done) { + var self = this, repeaterArray = [], ngBindPattern; + var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN); + if (startIndex >= 0) { + ngBindPattern = selector.substring(startIndex + 2, selector.length - 2); + var element = this.testDocument.find('*').filter(function() { + return self.jQuery(this).attr('ng:bind') == ngBindPattern; + }); + done(jqFn.apply(element, jqArgs)); + } else { + done(jqFn.apply(this.testDocument.find(selector), jqArgs)); + } + }); + }; + })(); + } + return futureJquery; }; -- cgit v1.2.3