jenkins-bot has submitted this change and it was merged. Change subject: Some basic QUnit tests for cx.util ......................................................................
Some basic QUnit tests for cx.util Change-Id: I94b17dae57d7f1ed5fb858718ad0c14225ff9242 --- M Resources.php A tests/qunit/base/ext.cx.util.test.js 2 files changed, 62 insertions(+), 0 deletions(-) Approvals: Santhosh: Looks good to me, approved jenkins-bot: Verified diff --git a/Resources.php b/Resources.php index 9a0ac02..87b4189 100644 --- a/Resources.php +++ b/Resources.php @@ -8,6 +8,7 @@ $dir = __DIR__; +// TODO: use the standard form $resourcePaths = array( 'localBasePath' => $dir . '/modules', 'remoteExtPath' => 'ContentTranslation/modules', @@ -434,3 +435,17 @@ ), ) + $resourcePaths; +$wgHooks['ResourceLoaderTestModules'][] = function ( array &$modules ) { + $resourcePaths = array( + 'localBasePath' => __DIR__, + 'remoteExtPath' => 'ContentTranslation', + ); + + $modules['qunit']['ext.cx.util.test'] = array( + 'scripts' => array( 'tests/qunit/base/ext.cx.util.test.js' ), + 'dependencies' => array( + 'ext.cx.util', + 'mediawiki.Uri', + ), + ) + $resourcePaths; +}; diff --git a/tests/qunit/base/ext.cx.util.test.js b/tests/qunit/base/ext.cx.util.test.js new file mode 100644 index 0000000..ab4e3e4 --- /dev/null +++ b/tests/qunit/base/ext.cx.util.test.js @@ -0,0 +1,47 @@ +/** + * @file + * @author Niklas Laxström + * @license GPL-2.0+ + */ + +( function ( $, mw ) { + 'use strict'; + + QUnit.module( 'ext.cx.util', QUnit.newMwEnvironment( { + config: { + wgContentTranslationDomainTemplate: '$1.example.com', + wgArticlePath: '/bunny/says/$1', + wgScriptPath: '/w' + } + } ) ); + + QUnit.test( 'getPageUrl', function ( assert ) { + var proto = new mw.Uri().protocol + '://'; + + QUnit.expect( 2 ); + + assert.strictEqual( + mw.cx.getPageUrl( 'es', 'Title' ), + proto + 'es.example.com/bunny/says/Title', + 'Simple title' + ); + + assert.strictEqual( + mw.cx.getPageUrl( 'fi', 'Longer title' ), + proto + 'fi.example.com/bunny/says/Longer title', + 'Title with space' + ); + } ); + + QUnit.test( 'getApiUrl', function ( assert ) { + var proto = new mw.Uri().protocol + '://'; + + QUnit.expect( 1 ); + + assert.strictEqual( + mw.cx.getApiUrl( 'he' ), + proto + 'he.example.com/w/api.php', + 'Basic test' + ); + } ); +}( jQuery, mediaWiki ) ); -- To view, visit https://gerrit.wikimedia.org/r/150555 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I94b17dae57d7f1ed5fb858718ad0c14225ff9242 Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits