2 var repeat = function ( input
, multiplier
) {
3 return new Array( multiplier
+ 1 ).join( input
);
6 // See also TitleTest.php#testSecureAndSplit
18 'File_talk:Example.svg',
23 // Length is 256 total, but only title part matters
24 'Category:' + repeat( 'x', 248 ),
32 // Bad characters forbidden regardless of wgLegalTitleChars
46 // XML/HTML character entity references
47 // Note: The ones with # are commented out as those are interpreted as fragment and
48 // as such end up being valid.
52 // Subject of NS_TALK does not roundtrip to NS_MAIN
53 'Talk:File:Example.svg',
54 // Directory navigation
68 // Extension separation is a js invention, for length
69 // purposes it is part of the title
70 repeat( 'x', 252 ) + '.json',
71 // Namespace prefix without actual title
78 QUnit
.module( 'mediawiki.Title', QUnit
.newMwEnvironment( {
79 // mw.Title relies on these three config vars
80 // Restore them after each test run
82 wgFormattedNamespaces
: {
101 // testing custom / localized namespace
104 // jscs: disable requireCamelCaseOrUpperCaseIdentifiers
128 // Testing custom namespaces and aliases
130 antarctic_waterfowl
: 100
132 // jscs: enable requireCamelCaseOrUpperCaseIdentifiers
133 wgCaseSensitiveNamespaces
: []
137 QUnit
.test( 'constructor', cases
.invalid
.length
, function ( assert
) {
139 for ( i
= 0; i
< cases
.valid
.length
; i
++ ) {
140 title
= new mw
.Title( cases
.valid
[ i
] );
142 for ( i
= 0; i
< cases
.invalid
.length
; i
++ ) {
143 /*jshint loopfunc:true */
144 title
= cases
.invalid
[ i
];
145 assert
.throws( function () {
146 return new mw
.Title( title
);
147 }, cases
.invalid
[ i
] );
151 QUnit
.test( 'newFromText', cases
.valid
.length
+ cases
.invalid
.length
, function ( assert
) {
153 for ( i
= 0; i
< cases
.valid
.length
; i
++ ) {
155 $.type( mw
.Title
.newFromText( cases
.valid
[ i
] ) ),
160 for ( i
= 0; i
< cases
.invalid
.length
; i
++ ) {
162 $.type( mw
.Title
.newFromText( cases
.invalid
[ i
] ) ),
169 QUnit
.test( 'makeTitle', 6, function ( assert
) {
170 var cases
, i
, title
, expected
,
176 [ NS_TEMPLATE
, 'Foo', 'Template:Foo' ],
177 [ NS_TEMPLATE
, 'Category:Foo', 'Template:Category:Foo' ],
178 [ NS_TEMPLATE
, 'Template:Foo', 'Template:Template:Foo' ],
179 [ NS_TALK
, 'Help:Foo', null ],
180 [ NS_TEMPLATE
, '<', null ],
181 [ NS_MAIN
, 'Help:Foo', 'Help:Foo' ]
184 for ( i
= 0; i
< cases
.length
; i
++ ) {
185 title
= mw
.Title
.makeTitle( cases
[ i
][ 0 ], cases
[ i
][ 1 ] );
186 expected
= cases
[ i
][ 2 ];
187 if ( expected
=== null ) {
188 assert
.strictEqual( title
, expected
);
190 assert
.strictEqual( title
.getPrefixedText(), expected
);
195 QUnit
.test( 'Basic parsing', 21, function ( assert
) {
197 title
= new mw
.Title( 'File:Foo_bar.JPG' );
199 assert
.equal( title
.getNamespaceId(), 6 );
200 assert
.equal( title
.getNamespacePrefix(), 'File:' );
201 assert
.equal( title
.getName(), 'Foo_bar' );
202 assert
.equal( title
.getNameText(), 'Foo bar' );
203 assert
.equal( title
.getExtension(), 'JPG' );
204 assert
.equal( title
.getDotExtension(), '.JPG' );
205 assert
.equal( title
.getMain(), 'Foo_bar.JPG' );
206 assert
.equal( title
.getMainText(), 'Foo bar.JPG' );
207 assert
.equal( title
.getPrefixedDb(), 'File:Foo_bar.JPG' );
208 assert
.equal( title
.getPrefixedText(), 'File:Foo bar.JPG' );
210 title
= new mw
.Title( 'Foo#bar' );
211 assert
.equal( title
.getPrefixedText(), 'Foo' );
212 assert
.equal( title
.getFragment(), 'bar' );
214 title
= new mw
.Title( '.foo' );
215 assert
.equal( title
.getPrefixedText(), '.foo' );
216 assert
.equal( title
.getName(), '' );
217 assert
.equal( title
.getNameText(), '' );
218 assert
.equal( title
.getExtension(), 'foo' );
219 assert
.equal( title
.getDotExtension(), '.foo' );
220 assert
.equal( title
.getMain(), '.foo' );
221 assert
.equal( title
.getMainText(), '.foo' );
222 assert
.equal( title
.getPrefixedDb(), '.foo' );
223 assert
.equal( title
.getPrefixedText(), '.foo' );
226 QUnit
.test( 'Transformation', 12, function ( assert
) {
229 title
= new mw
.Title( 'File:quux pif.jpg' );
230 assert
.equal( title
.getNameText(), 'Quux pif', 'First character of title' );
232 title
= new mw
.Title( 'File:Glarg_foo_glang.jpg' );
233 assert
.equal( title
.getNameText(), 'Glarg foo glang', 'Underscores' );
235 title
= new mw
.Title( 'User:ABC.DEF' );
236 assert
.equal( title
.toText(), 'User:ABC.DEF', 'Round trip text' );
237 assert
.equal( title
.getNamespaceId(), 2, 'Parse canonical namespace prefix' );
239 title
= new mw
.Title( 'Image:quux pix.jpg' );
240 assert
.equal( title
.getNamespacePrefix(), 'File:', 'Transform alias to canonical namespace' );
242 title
= new mw
.Title( 'uSEr:hAshAr' );
243 assert
.equal( title
.toText(), 'User:HAshAr' );
244 assert
.equal( title
.getNamespaceId(), 2, 'Case-insensitive namespace prefix' );
246 title
= new mw
.Title( 'Foo \u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000 bar' );
247 assert
.equal( title
.getMain(), 'Foo_bar', 'Merge multiple types of whitespace/underscores into a single underscore' );
249 title
= new mw
.Title( 'Foo\u200E\u200F\u202A\u202B\u202C\u202D\u202Ebar' );
250 assert
.equal( title
.getMain(), 'Foobar', 'Strip Unicode bidi override characters' );
252 // Regression test: Previously it would only detect an extension if there is no space after it
253 title
= new mw
.Title( 'Example.js ' );
254 assert
.equal( title
.getExtension(), 'js', 'Space after an extension is stripped' );
256 title
= new mw
.Title( 'Example#foo' );
257 assert
.equal( title
.getFragment(), 'foo', 'Fragment' );
259 title
= new mw
.Title( 'Example#_foo_bar baz_' );
260 assert
.equal( title
.getFragment(), ' foo bar baz', 'Fragment' );
263 QUnit
.test( 'Namespace detection and conversion', 10, function ( assert
) {
266 title
= new mw
.Title( 'File:User:Example' );
267 assert
.equal( title
.getNamespaceId(), 6, 'Titles can contain namespace prefixes, which are otherwise ignored' );
269 title
= new mw
.Title( 'Example', 6 );
270 assert
.equal( title
.getNamespaceId(), 6, 'Default namespace passed is used' );
272 title
= new mw
.Title( 'User:Example', 6 );
273 assert
.equal( title
.getNamespaceId(), 2, 'Included namespace prefix overrides the given default' );
275 title
= new mw
.Title( ':Example', 6 );
276 assert
.equal( title
.getNamespaceId(), 0, 'Colon forces main namespace' );
278 title
= new mw
.Title( 'something.PDF', 6 );
279 assert
.equal( title
.toString(), 'File:Something.PDF' );
281 title
= new mw
.Title( 'NeilK', 3 );
282 assert
.equal( title
.toString(), 'User_talk:NeilK' );
283 assert
.equal( title
.toText(), 'User talk:NeilK' );
285 title
= new mw
.Title( 'Frobisher', 100 );
286 assert
.equal( title
.toString(), 'Penguins:Frobisher' );
288 title
= new mw
.Title( 'antarctic_waterfowl:flightless_yet_cute.jpg' );
289 assert
.equal( title
.toString(), 'Penguins:Flightless_yet_cute.jpg' );
291 title
= new mw
.Title( 'Penguins:flightless_yet_cute.jpg' );
292 assert
.equal( title
.toString(), 'Penguins:Flightless_yet_cute.jpg' );
295 QUnit
.test( 'Throw error on invalid title', 1, function ( assert
) {
296 assert
.throws( function () {
297 return new mw
.Title( '' );
298 }, 'Throw error on empty string' );
301 QUnit
.test( 'Case-sensivity', 3, function ( assert
) {
305 mw
.config
.set( 'wgCaseSensitiveNamespaces', [] );
307 title
= new mw
.Title( 'article' );
308 assert
.equal( title
.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
310 // $wgCapitalLinks = false;
311 mw
.config
.set( 'wgCaseSensitiveNamespaces', [ 0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15 ] );
313 title
= new mw
.Title( 'article' );
314 assert
.equal( title
.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
316 title
= new mw
.Title( 'john', 2 );
317 assert
.equal( title
.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
320 QUnit
.test( 'toString / toText', 2, function ( assert
) {
321 var title
= new mw
.Title( 'Some random page' );
323 assert
.equal( title
.toString(), title
.getPrefixedDb() );
324 assert
.equal( title
.toText(), title
.getPrefixedText() );
327 QUnit
.test( 'getExtension', 7, function ( assert
) {
328 function extTest( pagename
, ext
, description
) {
329 var title
= new mw
.Title( pagename
);
330 assert
.equal( title
.getExtension(), ext
, description
|| pagename
);
333 extTest( 'MediaWiki:Vector.js', 'js' );
334 extTest( 'User:Example/common.css', 'css' );
335 extTest( 'File:Example.longextension', 'longextension', 'Extension parsing not limited (bug 36151)' );
336 extTest( 'Example/information.json', 'json', 'Extension parsing not restricted from any namespace' );
337 extTest( 'Foo.', null, 'Trailing dot is not an extension' );
338 extTest( 'Foo..', null, 'Trailing dots are not an extension' );
339 extTest( 'Foo.a.', null, 'Page name with dots and ending in a dot does not have an extension' );
341 // @broken: Throws an exception
342 // extTest( '.NET', null, 'Leading dot is (or is not?) an extension' );
345 QUnit
.test( 'exists', 3, function ( assert
) {
348 // Empty registry, checks default to null
350 title
= new mw
.Title( 'Some random page', 4 );
351 assert
.strictEqual( title
.exists(), null, 'Return null with empty existance registry' );
353 // Basic registry, checks default to boolean
354 mw
.Title
.exist
.set( [ 'Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules' ], true );
355 mw
.Title
.exist
.set( [ 'Does_not_exist', 'User:John', 'Foobar' ], false );
357 title
= new mw
.Title( 'Project:Sandbox rules' );
358 assert
.assertTrue( title
.exists(), 'Return true for page titles marked as existing' );
359 title
= new mw
.Title( 'Foobar' );
360 assert
.assertFalse( title
.exists(), 'Return false for page titles marked as nonexistent' );
364 QUnit
.test( 'getUrl', 4, function ( assert
) {
367 wgScript
: '/w/index.php',
368 wgArticlePath
: '/wiki/$1'
371 title
= new mw
.Title( 'Foobar' );
372 assert
.equal( title
.getUrl(), '/wiki/Foobar', 'Basic functionality, getUrl uses mw.util.getUrl' );
373 assert
.equal( title
.getUrl( { action
: 'edit' } ), '/w/index.php?title=Foobar&action=edit', 'Basic functionality, \'params\' parameter' );
375 title
= new mw
.Title( 'John Doe', 3 );
376 assert
.equal( title
.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
378 title
= new mw
.Title( 'John Cena#And_His_Name_Is', 3 );
379 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' );
382 QUnit
.test( 'newFromImg', 44, function ( assert
) {
383 var title
, i
, thisCase
, prefix
,
386 url
: '//upload.wikimedia.org/wikipedia/commons/thumb/b/bf/Princess_Alexandra_of_Denmark_%28later_Queen_Alexandra%2C_wife_of_Edward_VII%29_with_her_two_eldest_sons%2C_Prince_Albert_Victor_%28Eddy%29_and_George_Frederick_Ernest_Albert_%28later_George_V%29.jpg/939px-thumbnail.jpg',
387 typeOfUrl
: 'Hashed thumb with shortened path',
388 nameText
: 'Princess Alexandra of Denmark (later Queen Alexandra, wife of Edward VII) with her two eldest sons, Prince Albert Victor (Eddy) and George Frederick Ernest Albert (later George V)',
389 prefixedText
: 'File:Princess Alexandra of Denmark (later Queen Alexandra, wife of Edward VII) with her two eldest sons, Prince Albert Victor (Eddy) and George Frederick Ernest Albert (later George V).jpg'
393 url
: '//upload.wikimedia.org/wikipedia/commons/thumb/b/bf/Princess_Alexandra_of_Denmark_%28later_Queen_Alexandra%2C_wife_of_Edward_VII%29_with_her_two_eldest_sons%2C_Prince_Albert_Victor_%28Eddy%29_and_George_Frederick_Ernest_Albert_%28later_George_V%29.jpg/939px-ki708pr1r6g2dl5lbhvwdqxenhait13.jpg',
394 typeOfUrl
: 'Hashed thumb with sha1-ed path',
395 nameText
: 'Princess Alexandra of Denmark (later Queen Alexandra, wife of Edward VII) with her two eldest sons, Prince Albert Victor (Eddy) and George Frederick Ernest Albert (later George V)',
396 prefixedText
: 'File:Princess Alexandra of Denmark (later Queen Alexandra, wife of Edward VII) with her two eldest sons, Prince Albert Victor (Eddy) and George Frederick Ernest Albert (later George V).jpg'
400 url
: '/wiki/images/thumb/9/91/Anticlockwise_heliotrope%27s.jpg/99px-Anticlockwise_heliotrope%27s.jpg',
401 typeOfUrl
: 'Normal hashed directory thumbnail',
402 nameText
: 'Anticlockwise heliotrope\'s',
403 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
407 url
: '/wiki/images/thumb/8/80/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
408 typeOfUrl
: 'Normal hashed directory thumbnail with complex thumbnail parameters',
409 nameText
: 'Wikipedia-logo-v2',
410 prefixedText
: 'File:Wikipedia-logo-v2.svg'
414 url
: '//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
415 typeOfUrl
: 'Commons thumbnail',
416 nameText
: 'Wikipedia-logo-v2',
417 prefixedText
: 'File:Wikipedia-logo-v2.svg'
421 url
: '/wiki/images/9/91/Anticlockwise_heliotrope%27s.jpg',
422 typeOfUrl
: 'Full image',
423 nameText
: 'Anticlockwise heliotrope\'s',
424 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
428 url
: 'http://localhost/thumb.php?f=Stuffless_Figaro%27s.jpg&width=180',
429 typeOfUrl
: 'thumb.php-based thumbnail',
430 nameText
: 'Stuffless Figaro\'s',
431 prefixedText
: 'File:Stuffless Figaro\'s.jpg'
435 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
436 typeOfUrl
: 'Commons unhashed thumbnail',
437 nameText
: 'Wikipedia-logo-v2',
438 prefixedText
: 'File:Wikipedia-logo-v2.svg'
442 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
443 typeOfUrl
: 'Commons unhashed thumbnail with complex thumbnail parameters',
444 nameText
: 'Wikipedia-logo-v2',
445 prefixedText
: 'File:Wikipedia-logo-v2.svg'
449 url
: '/wiki/images/Anticlockwise_heliotrope%27s.jpg',
450 typeOfUrl
: 'Unhashed local file',
451 nameText
: 'Anticlockwise heliotrope\'s',
452 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
457 typeOfUrl
: 'Empty string'
462 typeOfUrl
: 'String with only alphabet characters'
466 url
: 'foobar.foobar',
467 typeOfUrl
: 'Not a file path'
471 url
: '/a/a0/blah blah blah',
472 typeOfUrl
: 'Space characters'
476 for ( i
= 0; i
< cases
.length
; i
++ ) {
477 thisCase
= cases
[ i
];
478 title
= mw
.Title
.newFromImg( { src
: thisCase
.url
} );
480 if ( thisCase
.nameText
!== undefined ) {
481 prefix
= '[' + thisCase
.typeOfUrl
+ ' URL' + '] ';
483 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
484 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
485 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
486 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
488 assert
.strictEqual( title
, null, thisCase
.typeOfUrl
+ ', should not produce an mw.Title object' );
493 QUnit
.test( 'getRelativeText', 5, function ( assert
) {
494 var i
, thisCase
, title
,
499 expectedResult
: ':Asd'
504 expectedResult
: 'Dfg'
507 text
: 'Template:Ghj',
509 expectedResult
: 'Template:Ghj'
519 expectedResult
: 'User:Hi'
523 for ( i
= 0; i
< cases
.length
; i
++ ) {
524 thisCase
= cases
[ i
];
526 title
= mw
.Title
.newFromText( thisCase
.text
);
527 assert
.equal( title
.getRelativeText( thisCase
.relativeTo
), thisCase
.expectedResult
);
531 QUnit
.test( 'normalizeExtension', 5, function ( assert
) {
532 var extension
, i
, thisCase
, prefix
,
537 description
: 'Extension already in canonical form'
542 description
: 'Extension lowercased in canonical form'
547 description
: 'Extension changed in canonical form'
552 description
: 'Extension lowercased and changed in canonical form'
557 description
: 'Extension invalid and discarded'
561 for ( i
= 0; i
< cases
.length
; i
++ ) {
562 thisCase
= cases
[ i
];
563 extension
= mw
.Title
.normalizeExtension( thisCase
.extension
);
565 prefix
= '[' + thisCase
.description
+ '] ';
566 assert
.equal( extension
, thisCase
.expected
, prefix
+ 'Extension as expected' );
570 QUnit
.test( 'newFromUserInput', 12, function ( assert
) {
571 var title
, i
, thisCase
, prefix
,
574 title
: 'DCS0001557854455.JPG',
575 expected
: 'DCS0001557854455.JPG',
576 description
: 'Title in normal namespace without anything invalid but with "file extension"'
579 title
: 'MediaWiki:Msg-awesome',
580 expected
: 'MediaWiki:Msg-awesome',
581 description
: 'Full title (page in MediaWiki namespace) supplied as string'
584 title
: 'The/Mw/Sound.flac',
585 defaultNamespace
: -2,
586 expected
: 'Media:The-Mw-Sound.flac',
587 description
: 'Page in Media-namespace without explicit options'
590 title
: 'File:The/Mw/Sound.kml',
595 expected
: 'File:The/Mw/Sound.kml',
596 description
: 'Page in File-namespace without explicit options'
599 title
: 'File:Foo.JPEG',
600 expected
: 'File:Foo.JPEG',
601 description
: 'Page in File-namespace with non-canonical extension'
604 title
: 'File:Foo.JPEG ',
605 expected
: 'File:Foo.JPEG',
606 description
: 'Page in File-namespace with trailing whitespace'
610 for ( i
= 0; i
< cases
.length
; i
++ ) {
611 thisCase
= cases
[ i
];
612 title
= mw
.Title
.newFromUserInput( thisCase
.title
, thisCase
.defaultNamespace
, thisCase
.options
);
614 if ( thisCase
.expected
!== undefined ) {
615 prefix
= '[' + thisCase
.description
+ '] ';
617 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
618 assert
.equal( title
.toText(), thisCase
.expected
, prefix
+ 'Title as expected' );
620 assert
.strictEqual( title
, null, thisCase
.description
+ ', should not produce an mw.Title object' );
625 QUnit
.test( 'newFromFileName', 54, function ( assert
) {
626 var title
, i
, thisCase
, prefix
,
629 fileName
: 'DCS0001557854455.JPG',
630 typeOfName
: 'Standard camera output',
631 nameText
: 'DCS0001557854455',
632 prefixedText
: 'File:DCS0001557854455.JPG'
635 fileName
: 'File:Sample.png',
636 typeOfName
: 'Carrying namespace',
637 nameText
: 'File-Sample',
638 prefixedText
: 'File:File-Sample.png'
641 fileName
: 'Treppe 2222 Test upload.jpg',
642 typeOfName
: 'File name with spaces in it and lower case file extension',
643 nameText
: 'Treppe 2222 Test upload',
644 prefixedText
: 'File:Treppe 2222 Test upload.jpg'
647 fileName
: 'I contain a \ttab.jpg',
648 typeOfName
: 'Name containing a tab character',
649 nameText
: 'I contain a tab',
650 prefixedText
: 'File:I contain a tab.jpg'
653 fileName
: 'I_contain multiple__ ___ _underscores.jpg',
654 typeOfName
: 'Name containing multiple underscores',
655 nameText
: 'I contain multiple underscores',
656 prefixedText
: 'File:I contain multiple underscores.jpg'
659 fileName
: 'I like ~~~~~~~~es.jpg',
660 typeOfName
: 'Name containing more than three consecutive tilde characters',
661 nameText
: 'I like ~~es',
662 prefixedText
: 'File:I like ~~es.jpg'
665 fileName
: 'BI\u200EDI.jpg',
666 typeOfName
: 'Name containing BIDI overrides',
668 prefixedText
: 'File:BIDI.jpg'
671 fileName
: '100%ab progress.jpg',
672 typeOfName
: 'File name with URL encoding',
673 nameText
: '100% ab progress',
674 prefixedText
: 'File:100% ab progress.jpg'
677 fileName
: '<([>]):/#.jpg',
678 typeOfName
: 'File name with characters not permitted in titles that are replaced',
679 nameText
: '((()))---',
680 prefixedText
: 'File:((()))---.jpg'
683 fileName
: 'spaces\u0009\u2000\u200A\u200Bx.djvu',
684 typeOfName
: 'File name with different kind of spaces',
685 nameText
: 'Spaces \u200Bx',
686 prefixedText
: 'File:Spaces \u200Bx.djvu'
689 fileName
: 'dot.dot.dot.dot.dotdot',
690 typeOfName
: 'File name with a lot of dots',
691 nameText
: 'Dot.dot.dot.dot',
692 prefixedText
: 'File:Dot.dot.dot.dot.dotdot'
695 fileName
: 'dot. dot ._dot',
696 typeOfName
: 'File name with multiple dots and spaces',
697 nameText
: 'Dot. dot',
698 prefixedText
: 'File:Dot. dot. dot'
701 fileName
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂.png',
702 typeOfName
: 'File name longer than 240 bytes',
703 nameText
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵',
704 prefixedText
: 'File:𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵.png'
708 typeOfName
: 'Empty string'
712 typeOfName
: 'String with only alphabet characters'
716 for ( i
= 0; i
< cases
.length
; i
++ ) {
717 thisCase
= cases
[ i
];
718 title
= mw
.Title
.newFromFileName( thisCase
.fileName
);
720 if ( thisCase
.nameText
!== undefined ) {
721 prefix
= '[' + thisCase
.typeOfName
+ '] ';
723 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
724 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
725 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
726 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
728 assert
.strictEqual( title
, null, thisCase
.typeOfName
+ ', should not produce an mw.Title object' );
733 }( mediaWiki
, jQuery
) );