QUnit.module( 'mediawiki.util', QUnit.newMwEnvironment( {
setup: function () {
$.fn.updateTooltipAccessKeys.setTestMode( true );
+ this.origConfig = mw.util.setOptionsForTest( {
+ FragmentMode: [ 'legacy', 'html5' ],
+ LoadScript: '/w/load.php'
+ } );
},
teardown: function () {
$.fn.updateTooltipAccessKeys.setTestMode( false );
+ mw.util.setOptionsForTest( this.origConfig );
},
messages: {
// Used by accessKeyLabel in test for addPortletLink
// Distant future: no legacy fallbacks
[ allNew, text, html5Encoded ]
].forEach( function ( testCase ) {
- mw.config.set( 'wgFragmentMode', testCase[ 0 ] );
+ mw.util.setOptionsForTest( { FragmentMode: testCase[ 0 ] } );
assert.strictEqual( util.escapeIdForAttribute( testCase[ 1 ] ), testCase[ 2 ] );
} );
// Distant future: no legacy fallbacks
[ allNew, text, html5Encoded ]
].forEach( function ( testCase ) {
- mw.config.set( 'wgFragmentMode', testCase[ 0 ] );
+ mw.util.setOptionsForTest( { FragmentMode: testCase[ 0 ] } );
assert.strictEqual( util.escapeIdForLink( testCase[ 1 ] ), testCase[ 2 ] );
} );
QUnit.test( 'wikiUrlencode', function ( assert ) {
assert.strictEqual( util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
// See also wfUrlencodeTest.php#provideURLS
- // eslint-disable-next-line jquery/no-each-util
+ // eslint-disable-next-line no-jquery/no-each-util
$.each( {
'+': '%2B',
'&': '%26',
href = util.getUrl( '#Fragment', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?action=edit#Fragment', 'empty title with query string and fragment' );
- mw.config.set( 'wgFragmentMode', [ 'legacy' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'legacy' ] } );
href = util.getUrl( 'Foo:Sandbox \xC4#Fragment \xC4', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?title=Foo:Sandbox_%C3%84&action=edit#Fragment_.C3.84', 'title with query string, fragment, and special characters' );
- mw.config.set( 'wgFragmentMode', [ 'html5' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'html5' ] } );
href = util.getUrl( 'Foo:Sandbox \xC4#Fragment \xC4', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?title=Foo:Sandbox_%C3%84&action=edit#Fragment_Ä', 'title with query string, fragment, and special characters' );
href = util.getUrl( 'Foo:%23#Fragment', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?title=Foo:%2523&action=edit#Fragment', 'title containing %23 (#), fragment, and a query string' );
- mw.config.set( 'wgFragmentMode', [ 'legacy' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'legacy' ] } );
href = util.getUrl( '#+&=:;@$-_.!*/[]<>\'§', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?action=edit#.2B.26.3D:.3B.40.24-_..21.2A.2F.5B.5D.3C.3E.27.C2.A7', 'fragment with various characters' );
- mw.config.set( 'wgFragmentMode', [ 'html5' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'html5' ] } );
href = util.getUrl( '#+&=:;@$-_.!*/[]<>\'§', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?action=edit#+&=:;@$-_.!*/[]<>\'§', 'fragment with various characters' );
} );
QUnit.test( 'wikiScript', function ( assert ) {
+ mw.util.setOptionsForTest( {
+ LoadScript: '/w/l.php'
+ } );
mw.config.set( {
// customized wgScript for T41103
wgScript: '/w/i.php',
- // customized wgLoadScript for T41103
- wgLoadScript: '/w/l.php',
wgScriptPath: '/w'
} );
assert.strictEqual( util.wikiScript( 'index' ), mw.config.get( 'wgScript' ),
'wikiScript( index ) returns wgScript'
);
- assert.strictEqual( util.wikiScript( 'load' ), mw.config.get( 'wgLoadScript' ),
- 'wikiScript( load ) returns wgLoadScript'
+ assert.strictEqual( util.wikiScript( 'load' ), '/w/l.php',
+ 'wikiScript( load ) returns /w/l.php'
);
assert.strictEqual( util.wikiScript( 'api' ), '/w/api.php', 'API path' );
} );
'Default modules', 't-rldm-nonexistent', 'List of all default modules ', 'd', '#t-rl-nonexistent' );
assert.strictEqual(
tbRLDMnonexistentid,
- $( '#p-test-tb li:last' )[ 0 ],
+ $( '#p-test-tb li' ).last()[ 0 ],
'Next node as non-matching CSS selector falls back to appending'
);
'Default modules', 't-rldm-empty-jquery', 'List of all default modules ', 'd', $( '#t-rl-nonexistent' ) );
assert.strictEqual(
tbRLDMemptyjquery,
- $( '#p-test-tb li:last' )[ 0 ],
+ $( '#p-test-tb li' ).last()[ 0 ],
'Next node as empty jQuery object falls back to appending'
);
} );