Permalink
Browse files

Client#and() is no longer queued

  • Loading branch information...
1 parent c07f698 commit 673055386f404a4e2531c38d3cebc98de5e97e7d Tj Holowaychuk committed Oct 7, 2010
Showing with 12 additions and 14 deletions.
  1. +4 −3 Readme.md
  2. +2 −6 lib/soda/client.js
  3. +1 −1 lib/soda/index.js
  4. +2 −2 package.json
  5. +3 −2 test/client.test.js
View
@@ -60,10 +60,11 @@ When chaining successful commands may receive a callback, which is useful for cu
.getTitle(function(title){
assert.equal('Hello World', title);
})
- .and(function(){
+ .and(function(browser){
// arbitrary callback
- // do whatever you need, "this"
- // is the client
+ // do whatever you need, "this" / the first arg
+ // are the Client instance
+ this.assertElementPresent('css=foo');
})
.testComplete()
.end(function(err){
View
@@ -220,19 +220,15 @@ Client.prototype.enqueue = function(cmd, args, fn){
};
/**
- * Queue an arbitrary callback `fn` when using the chaining api.
+ * Arbitrary callback `fn(this)` when using the chaining api.
*
* @param {Function} fn
* @return {Client}
* @api public
*/
Client.prototype.and = function(fn){
- var self = this;
- this.queue.push(function(){
- fn.call(self);
- self.queue.shift()();
- });
+ fn.call(this, this);
return this;
};
View
@@ -24,4 +24,4 @@ exports.createSauceClient = require('./sauce').createClient;
* @type String
*/
-exports.version = '0.0.2';
+exports.version = '0.1.0';
View
@@ -1,8 +1,8 @@
{
"name": "soda",
"description": "Selenium RC Node Adapter (with Saucelabs support)",
- "keywords": ["selenium", "saucelabs", "testing"],
- "version": "0.0.2",
+ "keywords": ["selenium", "saucelabs", "testing", "test", "tests"],
+ "version": "0.1.0",
"author": "TJ Holowaychuk <tj@learnboost.com>",
"main": "./lib/soda/index.js",
"engines": { "node": ">= 0.2.0" }
View
@@ -96,10 +96,11 @@ module.exports = {
.chain
.session()
.open('/')
- .assertTitle('Google')
- .and(function(){
+ .and(function(browser){
++called;
+ assert.equal(browser, client, 'and() first arg is not the client');
assert.equal(this, client, 'and() "this" is not the client');
+ this.assertTitle('Google');
})
.testComplete()
.end(function(err){

0 comments on commit 6730553

Please sign in to comment.