X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=blobdiff_plain;f=tests%2Fqunit%2Fsuites%2Fresources%2Fmediawiki%2Fmediawiki.Title.test.js;h=1bc4c06d82cbe28ce01c4bda92e27ca92013af13;hb=96f40f152aa6070ea98f41e194e9704194f917f8;hp=124c49f5b84a5625704b6e57c47dedf560cad61c;hpb=2353628e6f4ddb6a1ac7e070c69265a3319073e2;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js index 124c49f5b8..1bc4c06d82 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js @@ -1,79 +1,80 @@ ( function ( mw, $ ) { + /* eslint-disable camelcase */ var repeat = function ( input, multiplier ) { - return new Array( multiplier + 1 ).join( input ); - }, - cases = { + return new Array( multiplier + 1 ).join( input ); + }, // See also TitleTest.php#testSecureAndSplit - valid: [ - 'Sandbox', - 'A "B"', - 'A \'B\'', - '.com', - '~', - '"', - '\'', - 'Talk:Sandbox', - 'Talk:Foo:Sandbox', - 'File:Example.svg', - 'File_talk:Example.svg', - 'Foo/.../Sandbox', - 'Sandbox/...', - 'A~~', - ':A', - // Length is 256 total, but only title part matters - 'Category:' + repeat( 'x', 248 ), - repeat( 'x', 252 ) - ], - invalid: [ - '', - ':', - '__ __', - ' __ ', - // Bad characters forbidden regardless of wgLegalTitleChars - 'A [ B', - 'A ] B', - 'A { B', - 'A } B', - 'A < B', - 'A > B', - 'A | B', - 'A \t B', - 'A \n B', - // URL encoding - 'A%20B', - 'A%23B', - 'A%2523B', - // XML/HTML character entity references - // Note: The ones with # are commented out as those are interpreted as fragment and - // as such end up being valid. - 'A é B', - // 'A é B', - // 'A é B', - // Subject of NS_TALK does not roundtrip to NS_MAIN - 'Talk:File:Example.svg', - // Directory navigation - '.', - '..', - './Sandbox', - '../Sandbox', - 'Foo/./Sandbox', - 'Foo/../Sandbox', - 'Sandbox/.', - 'Sandbox/..', - // Tilde - 'A ~~~ Name', - 'A ~~~~ Signature', - 'A ~~~~~ Timestamp', - repeat( 'x', 256 ), - // Extension separation is a js invention, for length - // purposes it is part of the title - repeat( 'x', 252 ) + '.json', - // Namespace prefix without actual title - 'Talk:', - 'Category: ', - 'Category: #bar' - ] - }; + cases = { + valid: [ + 'Sandbox', + 'A "B"', + 'A \'B\'', + '.com', + '~', + '"', + '\'', + 'Talk:Sandbox', + 'Talk:Foo:Sandbox', + 'File:Example.svg', + 'File_talk:Example.svg', + 'Foo/.../Sandbox', + 'Sandbox/...', + 'A~~', + ':A', + // Length is 256 total, but only title part matters + 'Category:' + repeat( 'x', 248 ), + repeat( 'x', 252 ) + ], + invalid: [ + '', + ':', + '__ __', + ' __ ', + // Bad characters forbidden regardless of wgLegalTitleChars + 'A [ B', + 'A ] B', + 'A { B', + 'A } B', + 'A < B', + 'A > B', + 'A | B', + 'A \t B', + 'A \n B', + // URL encoding + 'A%20B', + 'A%23B', + 'A%2523B', + // XML/HTML character entity references + // Note: The ones with # are commented out as those are interpreted as fragment and + // as such end up being valid. + 'A é B', + // 'A é B', + // 'A é B', + // Subject of NS_TALK does not roundtrip to NS_MAIN + 'Talk:File:Example.svg', + // Directory navigation + '.', + '..', + './Sandbox', + '../Sandbox', + 'Foo/./Sandbox', + 'Foo/../Sandbox', + 'Sandbox/.', + 'Sandbox/..', + // Tilde + 'A ~~~ Name', + 'A ~~~~ Signature', + 'A ~~~~~ Timestamp', + repeat( 'x', 256 ), + // Extension separation is a js invention, for length + // purposes it is part of the title + repeat( 'x', 252 ) + '.json', + // Namespace prefix without actual title + 'Talk:', + 'Category: ', + 'Category: #bar' + ] + }; QUnit.module( 'mediawiki.Title', QUnit.newMwEnvironment( { // mw.Title relies on these three config vars @@ -101,7 +102,6 @@ // testing custom / localized namespace 100: 'Penguins' }, - // jscs: disable requireCamelCaseOrUpperCaseIdentifiers wgNamespaceIds: { media: -2, special: -1, @@ -129,26 +129,25 @@ penguins: 100, antarctic_waterfowl: 100 }, - // jscs: enable requireCamelCaseOrUpperCaseIdentifiers wgCaseSensitiveNamespaces: [] } } ) ); - QUnit.test( 'constructor', cases.invalid.length, function ( assert ) { + QUnit.test( 'constructor', function ( assert ) { var i, title; for ( i = 0; i < cases.valid.length; i++ ) { title = new mw.Title( cases.valid[ i ] ); } for ( i = 0; i < cases.invalid.length; i++ ) { - /*jshint loopfunc:true */ title = cases.invalid[ i ]; + // eslint-disable-next-line no-loop-func assert.throws( function () { return new mw.Title( title ); }, cases.invalid[ i ] ); } } ); - QUnit.test( 'newFromText', cases.valid.length + cases.invalid.length, function ( assert ) { + QUnit.test( 'newFromText', function ( assert ) { var i; for ( i = 0; i < cases.valid.length; i++ ) { assert.equal( @@ -166,7 +165,7 @@ } } ); - QUnit.test( 'makeTitle', 6, function ( assert ) { + QUnit.test( 'makeTitle', function ( assert ) { var cases, i, title, expected, NS_MAIN = 0, NS_TALK = 1, @@ -192,7 +191,7 @@ } } ); - QUnit.test( 'Basic parsing', 21, function ( assert ) { + QUnit.test( 'Basic parsing', function ( assert ) { var title; title = new mw.Title( 'File:Foo_bar.JPG' ); @@ -223,7 +222,7 @@ assert.equal( title.getPrefixedText(), '.foo' ); } ); - QUnit.test( 'Transformation', 12, function ( assert ) { + QUnit.test( 'Transformation', function ( assert ) { var title; title = new mw.Title( 'File:quux pif.jpg' ); @@ -260,7 +259,7 @@ assert.equal( title.getFragment(), ' foo bar baz', 'Fragment' ); } ); - QUnit.test( 'Namespace detection and conversion', 10, function ( assert ) { + QUnit.test( 'Namespace detection and conversion', function ( assert ) { var title; title = new mw.Title( 'File:User:Example' ); @@ -292,13 +291,13 @@ assert.equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' ); } ); - QUnit.test( 'Throw error on invalid title', 1, function ( assert ) { + QUnit.test( 'Throw error on invalid title', function ( assert ) { assert.throws( function () { return new mw.Title( '' ); }, 'Throw error on empty string' ); } ); - QUnit.test( 'Case-sensivity', 5, function ( assert ) { + QUnit.test( 'Case-sensivity', function ( assert ) { var title; // Default config @@ -323,14 +322,14 @@ assert.equal( title.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' ); } ); - QUnit.test( 'toString / toText', 2, function ( assert ) { + QUnit.test( 'toString / toText', function ( assert ) { var title = new mw.Title( 'Some random page' ); assert.equal( title.toString(), title.getPrefixedDb() ); assert.equal( title.toText(), title.getPrefixedText() ); } ); - QUnit.test( 'getExtension', 7, function ( assert ) { + QUnit.test( 'getExtension', function ( assert ) { function extTest( pagename, ext, description ) { var title = new mw.Title( pagename ); assert.equal( title.getExtension(), ext, description || pagename ); @@ -338,7 +337,7 @@ extTest( 'MediaWiki:Vector.js', 'js' ); extTest( 'User:Example/common.css', 'css' ); - extTest( 'File:Example.longextension', 'longextension', 'Extension parsing not limited (bug 36151)' ); + extTest( 'File:Example.longextension', 'longextension', 'Extension parsing not limited (T38151)' ); extTest( 'Example/information.json', 'json', 'Extension parsing not restricted from any namespace' ); extTest( 'Foo.', null, 'Trailing dot is not an extension' ); extTest( 'Foo..', null, 'Trailing dots are not an extension' ); @@ -348,7 +347,7 @@ // extTest( '.NET', null, 'Leading dot is (or is not?) an extension' ); } ); - QUnit.test( 'exists', 3, function ( assert ) { + QUnit.test( 'exists', function ( assert ) { var title; // Empty registry, checks default to null @@ -367,7 +366,7 @@ } ); - QUnit.test( 'getUrl', 4, function ( assert ) { + QUnit.test( 'getUrl', function ( assert ) { var title; mw.config.set( { wgScript: '/w/index.php', @@ -385,7 +384,7 @@ assert.equal( title.getUrl( { meme: true } ), '/w/index.php?title=User_talk:John_Cena&meme=true#And_His_Name_Is', 'title with fragment and query parameter' ); } ); - QUnit.test( 'newFromImg', 44, function ( assert ) { + QUnit.test( 'newFromImg', function ( assert ) { var title, i, thisCase, prefix, cases = [ { @@ -496,7 +495,7 @@ } } ); - QUnit.test( 'getRelativeText', 5, function ( assert ) { + QUnit.test( 'getRelativeText', function ( assert ) { var i, thisCase, title, cases = [ { @@ -534,7 +533,7 @@ } } ); - QUnit.test( 'normalizeExtension', 5, function ( assert ) { + QUnit.test( 'normalizeExtension', function ( assert ) { var extension, i, thisCase, prefix, cases = [ { @@ -573,7 +572,7 @@ } } ); - QUnit.test( 'newFromUserInput', 12, function ( assert ) { + QUnit.test( 'newFromUserInput', function ( assert ) { var title, i, thisCase, prefix, cases = [ { @@ -628,7 +627,7 @@ } } ); - QUnit.test( 'newFromFileName', 54, function ( assert ) { + QUnit.test( 'newFromFileName', function ( assert ) { var title, i, thisCase, prefix, cases = [ {