marionette-helper
Advanced tools
Comparing version 0.0.7 to 0.0.8
52
index.js
@@ -13,2 +13,3 @@ var Marionette = require('marionette-client'); | ||
/** | ||
@@ -57,4 +58,5 @@ * Make a new helper. | ||
/** | ||
* Similar to Marionette.Client#waitFor except that the test gets | ||
* executed in node rather than gecko. | ||
* ~*~*~*~*~ o_O Deprecated o_O ~*~*~*~*~ | ||
* Use client#waitFor instead! | ||
* | ||
* @param {Function} test some function that returns a boolean. | ||
@@ -67,10 +69,6 @@ * @param {Function} callback function to invoke when test pass or timeout. | ||
waitFor: function(test, callback, opt_context, opt_interval, opt_timeout) { | ||
// If context provided, bind test to context. | ||
if (opt_context) { | ||
test = test.bind(opt_context); | ||
} | ||
this._waitFor(test, callback, | ||
opt_interval || MarionetteHelper.DEFAULT_TEST_INTERVAL, | ||
opt_timeout || MarionetteHelper.DEFAULT_TEST_TIMEOUT); | ||
this.client.waitFor(test, { | ||
interval: opt_interval, | ||
timeout: opt_timeout | ||
}, callback); | ||
}, | ||
@@ -80,26 +78,2 @@ | ||
/** | ||
* Helper method for MarionetteHelper#waitFor. | ||
* @param {Function} test some function that returns a boolean. | ||
* @param {Function} callback function to invoke when test pass or timeout. | ||
* @param {number} interval test frequency in millis. | ||
* @param {number} timeout test timeout in millis. | ||
*/ | ||
_waitFor: function(test, callback, interval, timeout) { | ||
if (timeout <= 0) { | ||
callback(new Error('timeout exceeded for ' + test.toString())); | ||
return; | ||
} | ||
if (test()) { | ||
callback(null); | ||
return; | ||
} | ||
var next = this._waitFor.bind( | ||
this, test, callback, interval, timeout - interval); | ||
setTimeout(next, interval); | ||
}, | ||
/** | ||
* Find some element and wait for it to be displayed. | ||
@@ -128,10 +102,4 @@ * @param {Marionette.Element|string} el element or some css selector. | ||
function isElement(maybeElement) { | ||
if (!maybeElement) { | ||
return false; | ||
} | ||
if (maybeElement instanceof Marionette.Element) { | ||
return true; | ||
} | ||
return typeof(maybeElement.id) === 'string' && maybeElement.client; | ||
return maybeElement && (maybeElement instanceof Marionette.Element || | ||
(!!maybeElement.id && !!maybeElement.client)); | ||
} |
{ | ||
"name": "marionette-helper", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"author": { | ||
@@ -10,3 +10,3 @@ "name": "Gareth Aye", | ||
"dependencies": { | ||
"marionette-client": "~0.12.0" | ||
"marionette-client": "~0.15.2" | ||
}, | ||
@@ -13,0 +13,0 @@ |
@@ -9,3 +9,3 @@ suite('MarionetteHelper', function() { | ||
subject = client.helper; | ||
setTimeout(done, 2500); // In the stead of using the BootWatcher. | ||
setTimeout(done, 2500); // In the stead of using the BootWatcher. | ||
}); | ||
@@ -32,5 +32,15 @@ | ||
test.skip('#waitForElement', function() { | ||
// TODO(gaye) | ||
test('#waitForElement exists', function(done) { | ||
subject.waitForElement('#screen'); | ||
done(); | ||
}); | ||
test('#waitForElement does not exist', function(done) { | ||
try { | ||
subject.waitForElement('#not-so-much-there'); | ||
} catch (e) { | ||
assert.strictEqual(e.type, 'NoSuchElement'); | ||
done(); | ||
} | ||
}); | ||
}); |
5908
142
+ Addedmarionette-client@0.15.5(transitive)
- Removedmarionette-client@0.12.1(transitive)
Updatedmarionette-client@~0.15.2