Skip to content
This repository
Browse code

Client#and() is no longer queued

  • Loading branch information...
commit 673055386f404a4e2531c38d3cebc98de5e97e7d 1 parent c07f698
TJ Holowaychuk visionmedia authored
7 Readme.md
Source Rendered
@@ -60,10 +60,11 @@ When chaining successful commands may receive a callback, which is useful for cu
60 60 .getTitle(function(title){
61 61 assert.equal('Hello World', title);
62 62 })
63   - .and(function(){
  63 + .and(function(browser){
64 64 // arbitrary callback
65   - // do whatever you need, "this"
66   - // is the client
  65 + // do whatever you need, "this" / the first arg
  66 + // are the Client instance
  67 + this.assertElementPresent('css=foo');
67 68 })
68 69 .testComplete()
69 70 .end(function(err){
8 lib/soda/client.js
@@ -220,7 +220,7 @@ Client.prototype.enqueue = function(cmd, args, fn){
220 220 };
221 221
222 222 /**
223   - * Queue an arbitrary callback `fn` when using the chaining api.
  223 + * Arbitrary callback `fn(this)` when using the chaining api.
224 224 *
225 225 * @param {Function} fn
226 226 * @return {Client}
@@ -228,11 +228,7 @@ Client.prototype.enqueue = function(cmd, args, fn){
228 228 */
229 229
230 230 Client.prototype.and = function(fn){
231   - var self = this;
232   - this.queue.push(function(){
233   - fn.call(self);
234   - self.queue.shift()();
235   - });
  231 + fn.call(this, this);
236 232 return this;
237 233 };
238 234
2  lib/soda/index.js
@@ -24,4 +24,4 @@ exports.createSauceClient = require('./sauce').createClient;
24 24 * @type String
25 25 */
26 26
27   -exports.version = '0.0.2';
  27 +exports.version = '0.1.0';
4 package.json
... ... @@ -1,8 +1,8 @@
1 1 {
2 2 "name": "soda",
3 3 "description": "Selenium RC Node Adapter (with Saucelabs support)",
4   - "keywords": ["selenium", "saucelabs", "testing"],
5   - "version": "0.0.2",
  4 + "keywords": ["selenium", "saucelabs", "testing", "test", "tests"],
  5 + "version": "0.1.0",
6 6 "author": "TJ Holowaychuk <tj@learnboost.com>",
7 7 "main": "./lib/soda/index.js",
8 8 "engines": { "node": ">= 0.2.0" }
5 test/client.test.js
@@ -96,10 +96,11 @@ module.exports = {
96 96 .chain
97 97 .session()
98 98 .open('/')
99   - .assertTitle('Google')
100   - .and(function(){
  99 + .and(function(browser){
101 100 ++called;
  101 + assert.equal(browser, client, 'and() first arg is not the client');
102 102 assert.equal(this, client, 'and() "this" is not the client');
  103 + this.assertTitle('Google');
103 104 })
104 105 .testComplete()
105 106 .end(function(err){

0 comments on commit 6730553

Please sign in to comment.
Something went wrong with that request. Please try again.