funcunit
Advanced tools
Comparing version 3.4.1 to 3.4.2
@@ -6,5 +6,20 @@ var FuncUnit = require("funcunit/browser/core"); | ||
/* | ||
QUnit2 does not expose a generic `assert`. | ||
It is only accessible within each test. | ||
Thus we need to intercept the assert | ||
from each test in order to start/stop/ok. | ||
*/ | ||
var currentTestAssert; | ||
var originalTest = QUnit.test; | ||
QUnit.test = function funcunitTest (title, test) { | ||
return originalTest(title, function (assert) { | ||
currentTestAssert = assert; | ||
return test.apply(this, arugments); | ||
}); | ||
} | ||
return { | ||
pauseTest:function(){ | ||
done = FuncUnit.qunit2Assert.async(); | ||
done = currentTestAssert.async(); | ||
}, | ||
@@ -15,3 +30,3 @@ resumeTest: function(){ | ||
assertOK: function(assertion, message){ | ||
FuncUnit.qunit2Assert.ok(assertion, message) | ||
currentTestAssert.ok(assertion, message) | ||
}, | ||
@@ -18,0 +33,0 @@ equiv: function(expected, actual){ |
@@ -26,4 +26,2 @@ var jQuery = require("funcunit/browser/jquery"); | ||
assignQunit2Assert(FuncUnit); | ||
// if its a function, just run it in the queue | ||
@@ -84,12 +82,4 @@ if(typeof selector == "function"){ | ||
var assignQunit2Assert = function (func) { | ||
var callerFirstArgument = func.caller && func.caller.arguments[0]; | ||
if(callerFirstArgument && callerFirstArgument.test){ | ||
FuncUnit.qunit2Assert = callerFirstArgument; | ||
} | ||
}; | ||
oldFuncUnit.jQuery.extend(FuncUnit, oldFuncUnit, origFuncUnit) | ||
FuncUnit.prototype = origFuncUnit.prototype; | ||
module.exports = FuncUnit; |
@@ -13,3 +13,3 @@ var $ = require("funcunit/browser/jquery"); | ||
* @signature `wait(time, success)` | ||
* Waits a timeout before running the next command. Wait is an action and gets | ||
* Waits a timeout before running the next command. Wait is an action and gets | ||
* added to the queue. | ||
@@ -22,8 +22,7 @@ * @codestart | ||
* @param {Number} [time] The timeout in milliseconds. Defaults to 5000. | ||
* @param {Function} [success] A callback that will run | ||
* after the wait has completed, | ||
* @param {Function} [success] A callback that will run | ||
* after the wait has completed, | ||
* but before any more queued actions. | ||
*/ | ||
wait = function(time, success){ | ||
assignQunit2Assert(FuncUnit.wait); | ||
if(typeof time == 'function'){ | ||
@@ -74,3 +73,2 @@ success = time; | ||
branch = function(check1, success1, check2, success2, timeout){ | ||
assignQunit2Assert(FuncUnit.branch); | ||
FuncUnit.repeat({ | ||
@@ -107,3 +105,2 @@ method : function(print){ | ||
FuncUnit.repeat = function(options){ | ||
assignQunit2Assert(FuncUnit.repeat); | ||
var interval, | ||
@@ -129,7 +126,7 @@ stopped = false , | ||
result = options.method(print) | ||
} | ||
} | ||
catch (e) { | ||
//should we throw this too error? | ||
} | ||
if (result) { | ||
@@ -140,6 +137,6 @@ success(options.bind); | ||
} | ||
}, 10); | ||
}, | ||
@@ -153,3 +150,3 @@ success : options.success, | ||
}); | ||
} | ||
@@ -167,4 +164,3 @@ | ||
FuncUnit.animationEnd = function(){ | ||
assignQunit2Assert(FuncUnit.animationEnd); | ||
F("body").wait(200).size(function(){ | ||
F("body").wait(200).size(function(){ | ||
return F.win.$(':animated').length === 0; | ||
@@ -176,10 +172,2 @@ }); | ||
var assignQunit2Assert = function (func) { | ||
var callerFirstArgument = func.caller.arguments[0]; | ||
if(callerFirstArgument && callerFirstArgument.test){ | ||
FuncUnit.qunit2Assert = callerFirstArgument; | ||
} | ||
}; | ||
$.extend(FuncUnit.prototype, { | ||
@@ -198,3 +186,3 @@ /** | ||
* @param {String} [message] if provided, an assertion will be passed when this wait condition completes successfully | ||
* @return {FuncUnit} returns the funcUnit for chaining. | ||
* @return {FuncUnit} returns the funcUnit for chaining. | ||
*/ | ||
@@ -230,3 +218,3 @@ exists: function( timeout, success, message ) { | ||
* @param {String} [message] if provided, an assertion will be passed when this wait condition completes successfully | ||
* @return {FuncUnit} returns the funcUnit for chaining. | ||
* @return {FuncUnit} returns the funcUnit for chaining. | ||
*/ | ||
@@ -240,3 +228,3 @@ missing: function( timeout,success, message ) { | ||
* @signature `visible([timeout] [,success] [,message])` | ||
* Waits until the funcUnit selector is visible. | ||
* Waits until the funcUnit selector is visible. | ||
* @codestart | ||
@@ -263,3 +251,3 @@ * //waits until #foo is visible. | ||
* @signature `invisible([timeout] [,success] [,message])` | ||
* Waits until the selector is invisible. | ||
* Waits until the selector is invisible. | ||
* @codestart | ||
@@ -287,3 +275,3 @@ * //waits until #foo is invisible. | ||
* | ||
* Waits until some condition is true before calling the next action. Or if no checker function is provided, waits a | ||
* Waits until some condition is true before calling the next action. Or if no checker function is provided, waits a | ||
* timeout before calling the next queued method. This can be used as a flexible wait condition to check various things in the tested page: | ||
@@ -295,3 +283,3 @@ * @codestart | ||
* @codeend | ||
* @param {Number|Function} [checker] a checking function. It runs repeatedly until the condition becomes true or the timeout period passes. | ||
* @param {Number|Function} [checker] a checking function. It runs repeatedly until the condition becomes true or the timeout period passes. | ||
* If a number is provided, a time in milliseconds to wait before running the next queued method. | ||
@@ -306,3 +294,3 @@ * @param {Number} [timeout] overrides FuncUnit.timeout. If provided, the wait will fail if not completed before this timeout. | ||
FuncUnit.wait(timeout, success) | ||
return this; | ||
return this; | ||
} else { | ||
@@ -309,0 +297,0 @@ return this.size(checker, timeout, success, message) |
{ | ||
"name": "funcunit", | ||
"version": "3.4.1", | ||
"version": "3.4.2", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Bitovi", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
1064996
182
28561