From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- .../resources/mediawiki/mediawiki.util.test.js | 288 --------------------- 1 file changed, 288 deletions(-) delete mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js (limited to 'tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js') diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js deleted file mode 100644 index ababa8d9..00000000 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js +++ /dev/null @@ -1,288 +0,0 @@ -QUnit.module( 'mediawiki.util', QUnit.newMwEnvironment() ); - -QUnit.test( 'rawurlencode', 1, function ( assert ) { - assert.equal( mw.util.rawurlencode( 'Test:A & B/Here' ), 'Test%3AA%20%26%20B%2FHere' ); -}); - -QUnit.test( 'wikiUrlencode', 1, function ( assert ) { - assert.equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' ); -}); - -QUnit.test( 'wikiGetlink', 3, function ( assert ) { - // Not part of startUp module - mw.config.set( 'wgArticlePath', '/wiki/$1' ); - mw.config.set( 'wgPageName', 'Foobar' ); - - var hrefA = mw.util.wikiGetlink( 'Sandbox' ); - assert.equal( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' ); - - var hrefB = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' ); - assert.equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage', - 'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' ); - - var hrefC = mw.util.wikiGetlink(); - assert.equal( hrefC, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' ); -}); - -QUnit.test( 'wikiScript', 4, function ( assert ) { - mw.config.set({ - 'wgScript': '/w/i.php', // customized wgScript for bug 39103 - 'wgLoadScript': '/w/l.php', // customized wgLoadScript for bug 39103 - 'wgScriptPath': '/w', - 'wgScriptExtension': '.php' - }); - - assert.equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'wikiScript() returns wgScript' ); - assert.equal( mw.util.wikiScript( 'index' ), mw.config.get( 'wgScript' ), "wikiScript( 'index' ) returns wgScript" ); - assert.equal( mw.util.wikiScript( 'load' ), mw.config.get( 'wgLoadScript' ), "wikiScript( 'load' ) returns wgLoadScript" ); - assert.equal( mw.util.wikiScript( 'api' ), '/w/api.php', 'API path' ); -}); - -QUnit.test( 'addCSS', 3, function ( assert ) { - var $testEl = $( '
' ).attr( 'id', 'mw-addcsstest' ).appendTo( '#qunit-fixture' ); - - var style = mw.util.addCSS( '#mw-addcsstest { visibility: hidden; }' ); - assert.equal( typeof style, 'object', 'addCSS returned an object' ); - assert.strictEqual( style.disabled, false, 'property "disabled" is available and set to false' ); - - assert.equal( $testEl.css( 'visibility' ), 'hidden', 'Added style properties are in effect' ); - - // Clean up - $( style.ownerNode ).remove(); -}); - -QUnit.asyncTest( 'toggleToc', 4, function ( assert ) { - assert.strictEqual( mw.util.toggleToc(), null, 'Return null if there is no table of contents on the page.' ); - - var tocHtml = - '
' + - '
' + - '

Contents

' + - ' [Hide ]' + - '
' + - '
' + - '
', - $toc = $(tocHtml).appendTo( '#qunit-fixture' ), - $toggleLink = $( '#togglelink' ); - - assert.strictEqual( $toggleLink.length, 1, 'Toggle link is appended to the page.' ); - - var actionC = function() { - QUnit.start(); - }; - var actionB = function() { - assert.strictEqual( mw.util.toggleToc( $toggleLink, actionC ), true, 'Return boolean true if the TOC is now visible.' ); - }; - var actionA = function() { - assert.strictEqual( mw.util.toggleToc( $toggleLink, actionB ), false, 'Return boolean false if the TOC is now hidden.' ); - }; - - actionA(); -}); - -QUnit.test( 'getParamValue', 5, function ( assert ) { - var url1 = 'http://example.org/?foo=wrong&foo=right#&foo=bad'; - - assert.equal( mw.util.getParamValue( 'foo', url1 ), 'right', 'Use latest one, ignore hash' ); - assert.strictEqual( mw.util.getParamValue( 'bar', url1 ), null, 'Return null when not found' ); - - var url2 = 'http://example.org/#&foo=bad'; - assert.strictEqual( mw.util.getParamValue( 'foo', url2 ), null, 'Ignore hash if param is not in querystring but in hash (bug 27427)' ); - - var url3 = 'example.org?' + $.param({ 'TEST': 'a b+c' }); - assert.strictEqual( mw.util.getParamValue( 'TEST', url3 ), 'a b+c', 'Bug 30441: getParamValue must understand "+" encoding of space' ); - - var url4 = 'example.org?' + $.param({ 'TEST': 'a b+c d' }); // check for sloppy code from r95332 :) - assert.strictEqual( mw.util.getParamValue( 'TEST', url4 ), 'a b+c d', 'Bug 30441: getParamValue must understand "+" encoding of space (multiple spaces)' ); -}); - -QUnit.test( 'tooltipAccessKey', 3, function ( assert ) { - assert.equal( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'mw.util.tooltipAccessKeyPrefix must be a string' ); - assert.ok( mw.util.tooltipAccessKeyRegexp instanceof RegExp, 'mw.util.tooltipAccessKeyRegexp instance of RegExp' ); - assert.ok( mw.util.updateTooltipAccessKeys, 'mw.util.updateTooltipAccessKeys' ); -}); - -QUnit.test( '$content', 2, function ( assert ) { - assert.ok( mw.util.$content instanceof jQuery, 'mw.util.$content instance of jQuery' ); - assert.strictEqual( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' ); -}); - - -/** - * Portlet names are prefixed with 'p-test' to avoid conflict with core - * when running the test suite under a wiki page. - * Previously, test elements where invisible to the selector since only - * one element can have a given id. - */ -QUnit.test( 'addPortletLink', 8, function ( assert ) { - var pTestTb, pCustom, vectorTabs, tbRL, cuQuux, $cuQuux, tbMW, $tbMW, tbRLDM, caFoo; - pTestTb = '\ -
\ -
Toolbox
\ -
    \ -
    '; - pCustom = '\ -
    \ -
    Views
    \ -
      \ -
    • Foo
    • \ -
    • \ - \ -
    • \ -
    \ -
    '; - vectorTabs = '\ -
    \ -
    Views
    \ -
      \ -
      '; - - $( '#qunit-fixture' ).append( pTestTb, pCustom, vectorTabs ); - - tbRL = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/ResourceLoader', - 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l' ); - - assert.ok( $.isDomElement( tbRL ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' ); - - tbMW = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/', - 'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', tbRL ); - $tbMW = $( tbMW ); - - - assert.equal( $tbMW.attr( 'id' ), 't-mworg', 'Link has correct ID set' ); - assert.equal( $tbMW.closest( '.portlet' ).attr( 'id' ), 'p-test-tb', 'Link was inserted within correct portlet' ); - assert.equal( $tbMW.next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' ); - - cuQuux = mw.util.addPortletLink( 'p-test-custom', '#', 'Quux' ); - $cuQuux = $(cuQuux); - - assert.equal( - $( '#p-test-custom #c-barmenu ul li' ).length, - 1, - 'addPortletLink did not add the item to all