diff options
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step')
4 files changed, 70 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/README.md b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/README.md new file mode 100644 index 00000000..37af9df6 --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/README.md @@ -0,0 +1,18 @@ +QUnit.step() - A QUnit Addon For Testing execution in order +============================================================ + +This addon for QUnit adds a step method that allows you to assert +the proper sequence in which the code should execute. + +Example: + + test("example test", function () { + function x() { + QUnit.step(2, "function y should be called first"); + } + function y() { + QUnit.step(1); + } + y(); + x(); + });
\ No newline at end of file diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/qunit-step.js b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/qunit-step.js new file mode 100644 index 00000000..1ed3ff06 --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/qunit-step.js @@ -0,0 +1,25 @@ +QUnit.extend( QUnit, { + + /** + * Check the sequence/order + * + * @example step(1); setTimeout(function () { step(3); }, 100); step(2); + * @param Number expected The excepted step within the test() + * @param String message (optional) + */ + step: function (expected, message) { + this.config.current.step++; // increment internal step counter. + if (typeof message === "undefined") { + message = "step " + expected; + } + var actual = this.config.current.step; + QUnit.push(QUnit.equiv(actual, expected), actual, expected, message); + } +}); + +/** + * Reset the step counter for every test() + */ +QUnit.testStart(function () { + this.config.current.step = 0; +}); diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/step-test.js b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/step-test.js new file mode 100644 index 00000000..a78c534b --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/step-test.js @@ -0,0 +1,13 @@ +module('Step Addon'); +test("step", 3, function () { + QUnit.step(1, "step starts at 1"); + setTimeout(function () { + start(); + QUnit.step(3); + }, 100); + QUnit.step(2, "before the setTimeout callback is run"); + stop(); +}); +test("step counter", 1, function () { + QUnit.step(1, "each test has its own step counter"); +});
\ No newline at end of file diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/step.html b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/step.html new file mode 100644 index 00000000..95ba492d --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/qunit/addons/step/step.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="UTF-8" /> + <title>QUnit Test Suite - Step Addon</title> + <link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen"> + <script type="text/javascript" src="../../qunit/qunit.js"></script> + <script type="text/javascript" src="qunit-step.js"></script> + <script type="text/javascript" src="step-test.js"></script> +</head> +<body> + <div id="qunit"></div> +</body> +</html> |