Daniel Werner has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/60808


Change subject: Introduction of qunit-parameterized for usage in QUnit tests
......................................................................

Introduction of qunit-parameterized for usage in QUnit tests

Taken from https://github.com/AStepaniuk/qunit-parameterize/tree/master/test 
and under MIT license.
Put into its own resource loader module which can be required by registered 
test modules.

Change-Id: I9fe98e33a5fd58a8e14c1900503ae1f48e72dfbf
---
M DataValues/Resources.php
A DataValues/resources/qunit.parameterize/COPYING
A DataValues/resources/qunit.parameterize/qunit.parameterize.js
3 files changed, 95 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues 
refs/changes/08/60808/1

diff --git a/DataValues/Resources.php b/DataValues/Resources.php
index 1a4f7dc..197f2c3 100644
--- a/DataValues/Resources.php
+++ b/DataValues/Resources.php
@@ -76,6 +76,16 @@
                                'dataValues',
                        ),
                ),
+
+               // qunit-parameterize from 
https://github.com/AStepaniuk/qunit-parameterize
+               'qunit.parameterize' => $moduleTemplate + array(
+                       'scripts' => array(
+                               'qunit.parameterize/qunit.parameterize.js',
+                       ),
+                       'dependencies' => array(
+                               'jquery.qunit'
+                       )
+               ),
        );
 
 } );
diff --git a/DataValues/resources/qunit.parameterize/COPYING 
b/DataValues/resources/qunit.parameterize/COPYING
new file mode 100644
index 0000000..0b06a83
--- /dev/null
+++ b/DataValues/resources/qunit.parameterize/COPYING
@@ -0,0 +1,19 @@
+The MIT License (MIT)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
\ No newline at end of file
diff --git a/DataValues/resources/qunit.parameterize/qunit.parameterize.js 
b/DataValues/resources/qunit.parameterize/qunit.parameterize.js
new file mode 100644
index 0000000..5fe90a4
--- /dev/null
+++ b/DataValues/resources/qunit.parameterize/qunit.parameterize.js
@@ -0,0 +1,66 @@
+/**
+ * Parameterize v 0.2
+ * A QUnit Addon For Running Parameterized Tests
+ *
+ * @see https://github.com/AStepaniuk/qunit-parameterize
+ * @licence MIT licence
+ *
+ * @example <code>
+ * QUnit
+ * .cases( [
+ *     { a : 2, b : 2, expectedSum : 4 },
+ *     { a : 5, b : 5, expectedSum : 10 },
+ *     { a : 40, b : 2, expectedSum : 42 }
+ * ] )
+ * .test( 'Sum test', function( params, assert ) {
+ *     var actualSum = sum( params.a, params.b );
+ *     assert.equal( actualSum, params.expectedSum );
+ * } );
+ * </code>
+ */
+QUnit.cases = ( function( QUnit ) {
+       'use strict';
+
+       return function(testCases) {
+               var createTest = function(methodName, title, expected, 
callback, parameters) {
+                       QUnit[methodName](
+                               title,
+                               expected,
+                               function(assert) { return callback.call(this, 
parameters, assert); }
+                       );
+               };
+
+               var iterateTestCases = function(methodName, title, expected, 
callback) {
+                       if (!testCases) return;
+
+                       if (!callback) {
+                               callback = expected;
+                               expected = null;
+                       }
+
+                       for (var i = 0; i < testCases.length; ++i) {
+                               var parameters = testCases[i];
+
+                               var testCaseTitle = title;
+                               if (parameters.title) {
+                                       testCaseTitle += "[" + parameters.title 
+ "]";
+                               }
+
+                               createTest(methodName, testCaseTitle, expected, 
callback, parameters);
+                       }
+               }
+
+               return {
+                       test : function(title, expected, callback) {
+                               iterateTestCases("test", title, expected, 
callback);
+                               return this;
+                       },
+
+                       asyncTest : function(title, expected, callback) {
+                               iterateTestCases("asyncTest", title, expected, 
callback);
+                               return this;
+                       }
+               }
+       }
+
+}( QUnit ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/60808
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fe98e33a5fd58a8e14c1900503ae1f48e72dfbf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <daniel.wer...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to