Daniel Werner has uploaded a new change for review. https://gerrit.wikimedia.org/r/60864
Change subject: Restores DataValues.tests.js as dataValues.tests.js ...................................................................... Restores DataValues.tests.js as dataValues.tests.js Accidentally deleted in patch set 2a9a54c787c34ff351d5c7317755c41b592f9ac9 while DataValues.tests.js should have been renamed in dataValues.tests.js instead. Change-Id: I1c8864388a09e2e6a881ec1f40598cd0d9b70ae9 --- A DataValues/tests/qunit/dataValues.tests.js 1 file changed, 86 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues refs/changes/64/60864/1 diff --git a/DataValues/tests/qunit/dataValues.tests.js b/DataValues/tests/qunit/dataValues.tests.js new file mode 100644 index 0000000..633f91b --- /dev/null +++ b/DataValues/tests/qunit/dataValues.tests.js @@ -0,0 +1,86 @@ +/** + * @file + * @ingroup DataValues + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < [email protected] > + */ +( function( dv, $, QUnit ) { + 'use strict'; + + // Fix for most of our tests no having the number of required assertions. + // This is required since I214b3d4 got merged into core. + // TODO: figure out some non-global alternative to deal with this. + QUnit.config.requireExpects = false; + + QUnit.module( 'DataValues.js', QUnit.newMwEnvironment() ); + + QUnit.test( + 'getDataValues', + function( assert ) { + var dvs = dv.getDataValues(); + + assert.ok( $.isArray( dvs ), 'Returns an array' ); + + for ( var i = 0, s = dvs.length; i < s; i++ ) { + assert.ok( + typeof dvs[i] === 'string', + 'Returned DV type "' + dvs[i] + '" is a string' + ); + + assert.ok( + dv.hasDataValue( dvs[i] ), + 'Returned DV type "' + dvs[i] + '" is present according to hasDataValue' + ); + } + } + ); + + QUnit.test( + 'hasDataValue', + function( assert ) { + // Already partially tested in getDataValues + + assert.strictEqual( + dv.hasDataValue( 'in your code, being silly' ), + false, + 'Non existing DV type is not present' + ); + + var dvs = dv.getDataValues(); + + assert.strictEqual( + dv.hasDataValue( dvs.pop() ), + true, + 'Existing DV type is present' + ); + } + ); + + QUnit.test( + 'newDataValue', + function( assert ) { + // This test needs dv.MonolingualTextValue to be loaded and registered + + var dataValue = dv.newDataValue( + 'monolingualtext', + { + 'language': 'en', + 'text': '~=[,,_,,]:3' + } + ); + + assert.strictEqual( + dataValue.getText(), + '~=[,,_,,]:3', + 'Value was constructed and the text was set correctly' + ); + + assert.strictEqual( + dataValue.getLanguageCode(), + 'en', + 'Value was constructed and the language code was set correctly' + ); + } + ); + +}( dataValues, jQuery, QUnit ) ); -- To view, visit https://gerrit.wikimedia.org/r/60864 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1c8864388a09e2e6a881ec1f40598cd0d9b70ae9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: master Gerrit-Owner: Daniel Werner <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
