Skip to content

Commit

Permalink
Fixed callback signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Sep 7, 2010
1 parent 9de3c0f commit 346f4b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/google.js
Expand Up @@ -20,7 +20,7 @@ browser
.clickAndWait('btnG') .clickAndWait('btnG')
.assertTitle('Hello World - Google Search') .assertTitle('Hello World - Google Search')
.testComplete() .testComplete()
.done(function(err, res){ .done(function(err, body, res){
if (err) throw err; if (err) throw err;
console.log('done'); console.log('done');
}); });
10 changes: 5 additions & 5 deletions examples/google.nested.js
Expand Up @@ -13,12 +13,12 @@ var browser = soda.createClient({
}); });


browser.session(function(err){ browser.session(function(err){
browser.open('/', function(err, res){ browser.open('/', function(err, body){
browser.type('q', 'Hello World', function(err, res){ browser.type('q', 'Hello World', function(err, body){
browser.clickAndWait('btnG', function(err, res){ browser.clickAndWait('btnG', function(err, body){
browser.assertTitle('Hello World - Google Search', function(err, res){ browser.assertTitle('Hello World - Google Search', function(err, body){
if (err) throw err; if (err) throw err;
browser.testComplete(function(err, res){ browser.testComplete(function(err, body){
console.log('done'); console.log('done');
}); });
}); });
Expand Down
16 changes: 8 additions & 8 deletions lib/soda/client.js
Expand Up @@ -47,13 +47,13 @@ Client.prototype.session = function(fn){
if (!this.browser) throw new Error('browser required'); if (!this.browser) throw new Error('browser required');
if (!this.url) throw new Error('browser url required'); if (!this.url) throw new Error('browser url required');
if (this.queue) { if (this.queue) {
return this.enqueue('getNewBrowserSession', [this.browser, this.url], function(err, res){ return this.enqueue('getNewBrowserSession', [this.browser, this.url], function(err, body){
self.sid = res.body; self.sid = body;
}); });
} else { } else {
this.command('getNewBrowserSession', [this.browser, this.url], function(err, res){ this.command('getNewBrowserSession', [this.browser, this.url], function(err, body){
if (err) return fn(err); if (err) return fn(err);
fn(null, self.sid = res.body); fn(null, self.sid = body);
}); });
} }
}; };
Expand Down Expand Up @@ -163,14 +163,14 @@ Client.prototype.done = function(fn){
Client.prototype.enqueue = function(cmd, args, fn){ Client.prototype.enqueue = function(cmd, args, fn){
var self = this; var self = this;
this.queue.push(function(){ this.queue.push(function(){
self.command(cmd, args, function(err, res){ self.command(cmd, args, function(err, body, res){
fn && fn(err, res); fn && fn(err, body, res);
if (err) { if (err) {
self.done(err, res); self.done(err, body, res);
} else if (self.queue.length) { } else if (self.queue.length) {
self.queue.shift()(); self.queue.shift()();
} else { } else {
self.done(null, res); self.done(null, body, res);
} }
}); });
}); });
Expand Down

0 comments on commit 346f4b7

Please sign in to comment.