chai-wait-for
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -90,13 +90,52 @@ "use strict"; | ||
}); | ||
const isChainableMethod = getterName => Object.prototype.hasOwnProperty.call(Assertion.prototype.__methods, getterName); | ||
getterNames.forEach(getterName => { | ||
Object.defineProperty(WaitFor.prototype, getterName, { | ||
get() { | ||
return new WaitFor(this.options, () => { | ||
const assertion = this.buildAssertion(); | ||
return assertion[getterName]; | ||
}); | ||
}, | ||
if (isChainableMethod(getterName)) { | ||
Object.defineProperty(WaitFor.prototype, getterName, { | ||
get() { | ||
const obj = new WaitFor(this.options, () => { | ||
const assertion = this.buildAssertion(); | ||
return assertion[getterName]; | ||
}); | ||
configurable: true | ||
}); | ||
function chainable() { | ||
return new WaitFor(this.options, () => { | ||
const assertion = this.buildAssertion(); | ||
return assertion[getterName].apply(assertion, arguments); | ||
}); | ||
} | ||
for (const methodName of methodNames) { | ||
chainable[methodName] = obj[methodName].bind(obj); | ||
} | ||
for (const getterName of getterNames) { | ||
Object.defineProperty(chainable, getterName, { | ||
get() { | ||
return obj[getterName]; | ||
}, | ||
configurable: true | ||
}); | ||
} | ||
return chainable; | ||
}, | ||
configurable: true | ||
}); | ||
} else { | ||
Object.defineProperty(WaitFor.prototype, getterName, { | ||
get() { | ||
return new WaitFor(this.options, () => { | ||
const assertion = this.buildAssertion(); | ||
return assertion[getterName]; | ||
}); | ||
}, | ||
configurable: true | ||
}); | ||
} | ||
}); | ||
@@ -103,0 +142,0 @@ }; |
90
index.js
@@ -187,15 +187,85 @@ "use strict"; | ||
}); | ||
var isChainableMethod = function isChainableMethod(getterName) { | ||
return Object.prototype.hasOwnProperty.call(Assertion.prototype.__methods, getterName); | ||
}; | ||
getterNames.forEach(function (getterName) { | ||
Object.defineProperty(WaitFor.prototype, getterName, { | ||
get: function get() { | ||
var _this3 = this; | ||
if (isChainableMethod(getterName)) { | ||
Object.defineProperty(WaitFor.prototype, getterName, { | ||
get: function get() { | ||
var _this3 = this; | ||
return new WaitFor(this.options, function () { | ||
var assertion = _this3.buildAssertion(); | ||
var obj = new WaitFor(this.options, function () { | ||
var assertion = _this3.buildAssertion(); | ||
return assertion[getterName]; | ||
}); | ||
}, | ||
configurable: true | ||
}); | ||
return assertion[getterName]; | ||
}); | ||
function chainable() { | ||
var _arguments2 = arguments, | ||
_this4 = this; | ||
return new WaitFor(this.options, function () { | ||
var assertion = _this4.buildAssertion(); | ||
return assertion[getterName].apply(assertion, _arguments2); | ||
}); | ||
} | ||
var _iterator2 = _createForOfIteratorHelper(methodNames), | ||
_step2; | ||
try { | ||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { | ||
var methodName = _step2.value; | ||
chainable[methodName] = obj[methodName].bind(obj); | ||
} | ||
} catch (err) { | ||
_iterator2.e(err); | ||
} finally { | ||
_iterator2.f(); | ||
} | ||
var _iterator3 = _createForOfIteratorHelper(getterNames), | ||
_step3; | ||
try { | ||
var _loop = function _loop() { | ||
var getterName = _step3.value; | ||
Object.defineProperty(chainable, getterName, { | ||
get: function get() { | ||
return obj[getterName]; | ||
}, | ||
configurable: true | ||
}); | ||
}; | ||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { | ||
_loop(); | ||
} | ||
} catch (err) { | ||
_iterator3.e(err); | ||
} finally { | ||
_iterator3.f(); | ||
} | ||
return chainable; | ||
}, | ||
configurable: true | ||
}); | ||
} else { | ||
Object.defineProperty(WaitFor.prototype, getterName, { | ||
get: function get() { | ||
var _this5 = this; | ||
return new WaitFor(this.options, function () { | ||
var assertion = _this5.buildAssertion(); | ||
return assertion[getterName]; | ||
}); | ||
}, | ||
configurable: true | ||
}); | ||
} | ||
}); | ||
@@ -202,0 +272,0 @@ }; |
{ | ||
"name": "chai-wait-for", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "poll until an assertion succeeds", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
401865
334