Skip to content

Commit

Permalink
Client#and() is no longer queued
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 7, 2010
1 parent c07f698 commit 6730553
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
7 changes: 4 additions & 3 deletions Readme.md
Expand Up @@ -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){
Expand Down
8 changes: 2 additions & 6 deletions lib/soda/client.js
Expand Up @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/soda/index.js
Expand Up @@ -24,4 +24,4 @@ exports.createSauceClient = require('./sauce').createClient;
* @type String
*/

exports.version = '0.0.2';
exports.version = '0.1.0';
4 changes: 2 additions & 2 deletions package.json
@@ -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" }
Expand Down
5 changes: 3 additions & 2 deletions test/client.test.js
Expand Up @@ -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){
Expand Down

0 comments on commit 6730553

Please sign in to comment.