3 var repeat = function ( input
, multiplier
) {
4 return new Array( multiplier
+ 1 ).join( input
);
7 // See also TitleTest.php#testSecureAndSplit
19 'File_talk:Example.svg',
24 // Length is 256 total, but only title part matters
25 'Category:' + repeat( 'x', 248 ),
33 // Bad characters forbidden regardless of wgLegalTitleChars
47 // XML/HTML character entity references
48 // Note: The ones with # are commented out as those are interpreted as fragment and
49 // as such end up being valid.
53 // Subject of NS_TALK does not roundtrip to NS_MAIN
54 'Talk:File:Example.svg',
55 // Directory navigation
69 // Extension separation is a js invention, for length
70 // purposes it is part of the title
71 repeat( 'x', 252 ) + '.json',
72 // Namespace prefix without actual title
79 QUnit
.module( 'mediawiki.Title', QUnit
.newMwEnvironment( {
80 // mw.Title relies on these three config vars
81 // Restore them after each test run
83 wgFormattedNamespaces
: {
102 // testing custom / localized namespace
105 // jscs: disable requireCamelCaseOrUpperCaseIdentifiers
129 // Testing custom namespaces and aliases
131 antarctic_waterfowl
: 100
133 // jscs: enable requireCamelCaseOrUpperCaseIdentifiers
134 wgCaseSensitiveNamespaces
: []
138 QUnit
.test( 'constructor', cases
.invalid
.length
, function ( assert
) {
140 for ( i
= 0; i
< cases
.valid
.length
; i
++ ) {
141 title
= new mw
.Title( cases
.valid
[ i
] );
143 for ( i
= 0; i
< cases
.invalid
.length
; i
++ ) {
144 /*jshint loopfunc:true */
145 title
= cases
.invalid
[ i
];
146 assert
.throws( function () {
147 return new mw
.Title( title
);
148 }, cases
.invalid
[ i
] );
152 QUnit
.test( 'newFromText', cases
.valid
.length
+ cases
.invalid
.length
, function ( assert
) {
154 for ( i
= 0; i
< cases
.valid
.length
; i
++ ) {
156 $.type( mw
.Title
.newFromText( cases
.valid
[ i
] ) ),
161 for ( i
= 0; i
< cases
.invalid
.length
; i
++ ) {
163 $.type( mw
.Title
.newFromText( cases
.invalid
[ i
] ) ),
170 QUnit
.test( 'makeTitle', 6, function ( assert
) {
171 var cases
, i
, title
, expected
,
177 [ NS_TEMPLATE
, 'Foo', 'Template:Foo' ],
178 [ NS_TEMPLATE
, 'Category:Foo', 'Template:Category:Foo' ],
179 [ NS_TEMPLATE
, 'Template:Foo', 'Template:Template:Foo' ],
180 [ NS_TALK
, 'Help:Foo', null ],
181 [ NS_TEMPLATE
, '<', null ],
182 [ NS_MAIN
, 'Help:Foo', 'Help:Foo' ]
185 for ( i
= 0; i
< cases
.length
; i
++ ) {
186 title
= mw
.Title
.makeTitle( cases
[ i
][ 0 ], cases
[ i
][ 1 ] );
187 expected
= cases
[ i
][ 2 ];
188 if ( expected
=== null ) {
189 assert
.strictEqual( title
, expected
);
191 assert
.strictEqual( title
.getPrefixedText(), expected
);
196 QUnit
.test( 'Basic parsing', 21, function ( assert
) {
198 title
= new mw
.Title( 'File:Foo_bar.JPG' );
200 assert
.equal( title
.getNamespaceId(), 6 );
201 assert
.equal( title
.getNamespacePrefix(), 'File:' );
202 assert
.equal( title
.getName(), 'Foo_bar' );
203 assert
.equal( title
.getNameText(), 'Foo bar' );
204 assert
.equal( title
.getExtension(), 'JPG' );
205 assert
.equal( title
.getDotExtension(), '.JPG' );
206 assert
.equal( title
.getMain(), 'Foo_bar.JPG' );
207 assert
.equal( title
.getMainText(), 'Foo bar.JPG' );
208 assert
.equal( title
.getPrefixedDb(), 'File:Foo_bar.JPG' );
209 assert
.equal( title
.getPrefixedText(), 'File:Foo bar.JPG' );
211 title
= new mw
.Title( 'Foo#bar' );
212 assert
.equal( title
.getPrefixedText(), 'Foo' );
213 assert
.equal( title
.getFragment(), 'bar' );
215 title
= new mw
.Title( '.foo' );
216 assert
.equal( title
.getPrefixedText(), '.foo' );
217 assert
.equal( title
.getName(), '' );
218 assert
.equal( title
.getNameText(), '' );
219 assert
.equal( title
.getExtension(), 'foo' );
220 assert
.equal( title
.getDotExtension(), '.foo' );
221 assert
.equal( title
.getMain(), '.foo' );
222 assert
.equal( title
.getMainText(), '.foo' );
223 assert
.equal( title
.getPrefixedDb(), '.foo' );
224 assert
.equal( title
.getPrefixedText(), '.foo' );
227 QUnit
.test( 'Transformation', 12, function ( assert
) {
230 title
= new mw
.Title( 'File:quux pif.jpg' );
231 assert
.equal( title
.getNameText(), 'Quux pif', 'First character of title' );
233 title
= new mw
.Title( 'File:Glarg_foo_glang.jpg' );
234 assert
.equal( title
.getNameText(), 'Glarg foo glang', 'Underscores' );
236 title
= new mw
.Title( 'User:ABC.DEF' );
237 assert
.equal( title
.toText(), 'User:ABC.DEF', 'Round trip text' );
238 assert
.equal( title
.getNamespaceId(), 2, 'Parse canonical namespace prefix' );
240 title
= new mw
.Title( 'Image:quux pix.jpg' );
241 assert
.equal( title
.getNamespacePrefix(), 'File:', 'Transform alias to canonical namespace' );
243 title
= new mw
.Title( 'uSEr:hAshAr' );
244 assert
.equal( title
.toText(), 'User:HAshAr' );
245 assert
.equal( title
.getNamespaceId(), 2, 'Case-insensitive namespace prefix' );
247 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' );
248 assert
.equal( title
.getMain(), 'Foo_bar', 'Merge multiple types of whitespace/underscores into a single underscore' );
250 title
= new mw
.Title( 'Foo\u200E\u200F\u202A\u202B\u202C\u202D\u202Ebar' );
251 assert
.equal( title
.getMain(), 'Foobar', 'Strip Unicode bidi override characters' );
253 // Regression test: Previously it would only detect an extension if there is no space after it
254 title
= new mw
.Title( 'Example.js ' );
255 assert
.equal( title
.getExtension(), 'js', 'Space after an extension is stripped' );
257 title
= new mw
.Title( 'Example#foo' );
258 assert
.equal( title
.getFragment(), 'foo', 'Fragment' );
260 title
= new mw
.Title( 'Example#_foo_bar baz_' );
261 assert
.equal( title
.getFragment(), ' foo bar baz', 'Fragment' );
264 QUnit
.test( 'Namespace detection and conversion', 10, function ( assert
) {
267 title
= new mw
.Title( 'File:User:Example' );
268 assert
.equal( title
.getNamespaceId(), 6, 'Titles can contain namespace prefixes, which are otherwise ignored' );
270 title
= new mw
.Title( 'Example', 6 );
271 assert
.equal( title
.getNamespaceId(), 6, 'Default namespace passed is used' );
273 title
= new mw
.Title( 'User:Example', 6 );
274 assert
.equal( title
.getNamespaceId(), 2, 'Included namespace prefix overrides the given default' );
276 title
= new mw
.Title( ':Example', 6 );
277 assert
.equal( title
.getNamespaceId(), 0, 'Colon forces main namespace' );
279 title
= new mw
.Title( 'something.PDF', 6 );
280 assert
.equal( title
.toString(), 'File:Something.PDF' );
282 title
= new mw
.Title( 'NeilK', 3 );
283 assert
.equal( title
.toString(), 'User_talk:NeilK' );
284 assert
.equal( title
.toText(), 'User talk:NeilK' );
286 title
= new mw
.Title( 'Frobisher', 100 );
287 assert
.equal( title
.toString(), 'Penguins:Frobisher' );
289 title
= new mw
.Title( 'antarctic_waterfowl:flightless_yet_cute.jpg' );
290 assert
.equal( title
.toString(), 'Penguins:Flightless_yet_cute.jpg' );
292 title
= new mw
.Title( 'Penguins:flightless_yet_cute.jpg' );
293 assert
.equal( title
.toString(), 'Penguins:Flightless_yet_cute.jpg' );
296 QUnit
.test( 'Throw error on invalid title', 1, function ( assert
) {
297 assert
.throws( function () {
298 return new mw
.Title( '' );
299 }, 'Throw error on empty string' );
302 QUnit
.test( 'Case-sensivity', 3, function ( assert
) {
306 mw
.config
.set( 'wgCaseSensitiveNamespaces', [] );
308 title
= new mw
.Title( 'article' );
309 assert
.equal( title
.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
311 // $wgCapitalLinks = false;
312 mw
.config
.set( 'wgCaseSensitiveNamespaces', [ 0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15 ] );
314 title
= new mw
.Title( 'article' );
315 assert
.equal( title
.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
317 title
= new mw
.Title( 'john', 2 );
318 assert
.equal( title
.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
321 QUnit
.test( 'toString / toText', 2, function ( assert
) {
322 var title
= new mw
.Title( 'Some random page' );
324 assert
.equal( title
.toString(), title
.getPrefixedDb() );
325 assert
.equal( title
.toText(), title
.getPrefixedText() );
328 QUnit
.test( 'getExtension', 7, function ( assert
) {
329 function extTest( pagename
, ext
, description
) {
330 var title
= new mw
.Title( pagename
);
331 assert
.equal( title
.getExtension(), ext
, description
|| pagename
);
334 extTest( 'MediaWiki:Vector.js', 'js' );
335 extTest( 'User:Example/common.css', 'css' );
336 extTest( 'File:Example.longextension', 'longextension', 'Extension parsing not limited (bug 36151)' );
337 extTest( 'Example/information.json', 'json', 'Extension parsing not restricted from any namespace' );
338 extTest( 'Foo.', null, 'Trailing dot is not an extension' );
339 extTest( 'Foo..', null, 'Trailing dots are not an extension' );
340 extTest( 'Foo.a.', null, 'Page name with dots and ending in a dot does not have an extension' );
342 // @broken: Throws an exception
343 // extTest( '.NET', null, 'Leading dot is (or is not?) an extension' );
346 QUnit
.test( 'exists', 3, function ( assert
) {
349 // Empty registry, checks default to null
351 title
= new mw
.Title( 'Some random page', 4 );
352 assert
.strictEqual( title
.exists(), null, 'Return null with empty existance registry' );
354 // Basic registry, checks default to boolean
355 mw
.Title
.exist
.set( [ 'Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules' ], true );
356 mw
.Title
.exist
.set( [ 'Does_not_exist', 'User:John', 'Foobar' ], false );
358 title
= new mw
.Title( 'Project:Sandbox rules' );
359 assert
.assertTrue( title
.exists(), 'Return true for page titles marked as existing' );
360 title
= new mw
.Title( 'Foobar' );
361 assert
.assertFalse( title
.exists(), 'Return false for page titles marked as nonexistent' );
365 QUnit
.test( 'getUrl', 4, function ( assert
) {
368 wgScript
: '/w/index.php',
369 wgArticlePath
: '/wiki/$1'
372 title
= new mw
.Title( 'Foobar' );
373 assert
.equal( title
.getUrl(), '/wiki/Foobar', 'Basic functionality, getUrl uses mw.util.getUrl' );
374 assert
.equal( title
.getUrl( { action
: 'edit' } ), '/w/index.php?title=Foobar&action=edit', 'Basic functionality, \'params\' parameter' );
376 title
= new mw
.Title( 'John Doe', 3 );
377 assert
.equal( title
.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
379 title
= new mw
.Title( 'John Cena#And_His_Name_Is', 3 );
380 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' );
383 QUnit
.test( 'newFromImg', 44, function ( assert
) {
384 var title
, i
, thisCase
, prefix
,
387 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',
388 typeOfUrl
: 'Hashed thumb with shortened path',
389 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)',
390 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'
394 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',
395 typeOfUrl
: 'Hashed thumb with sha1-ed path',
396 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)',
397 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'
401 url
: '/wiki/images/thumb/9/91/Anticlockwise_heliotrope%27s.jpg/99px-Anticlockwise_heliotrope%27s.jpg',
402 typeOfUrl
: 'Normal hashed directory thumbnail',
403 nameText
: 'Anticlockwise heliotrope\'s',
404 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
408 url
: '/wiki/images/thumb/8/80/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
409 typeOfUrl
: 'Normal hashed directory thumbnail with complex thumbnail parameters',
410 nameText
: 'Wikipedia-logo-v2',
411 prefixedText
: 'File:Wikipedia-logo-v2.svg'
415 url
: '//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
416 typeOfUrl
: 'Commons thumbnail',
417 nameText
: 'Wikipedia-logo-v2',
418 prefixedText
: 'File:Wikipedia-logo-v2.svg'
422 url
: '/wiki/images/9/91/Anticlockwise_heliotrope%27s.jpg',
423 typeOfUrl
: 'Full image',
424 nameText
: 'Anticlockwise heliotrope\'s',
425 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
429 url
: 'http://localhost/thumb.php?f=Stuffless_Figaro%27s.jpg&width=180',
430 typeOfUrl
: 'thumb.php-based thumbnail',
431 nameText
: 'Stuffless Figaro\'s',
432 prefixedText
: 'File:Stuffless Figaro\'s.jpg'
436 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
437 typeOfUrl
: 'Commons unhashed thumbnail',
438 nameText
: 'Wikipedia-logo-v2',
439 prefixedText
: 'File:Wikipedia-logo-v2.svg'
443 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
444 typeOfUrl
: 'Commons unhashed thumbnail with complex thumbnail parameters',
445 nameText
: 'Wikipedia-logo-v2',
446 prefixedText
: 'File:Wikipedia-logo-v2.svg'
450 url
: '/wiki/images/Anticlockwise_heliotrope%27s.jpg',
451 typeOfUrl
: 'Unhashed local file',
452 nameText
: 'Anticlockwise heliotrope\'s',
453 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
458 typeOfUrl
: 'Empty string'
463 typeOfUrl
: 'String with only alphabet characters'
467 url
: 'foobar.foobar',
468 typeOfUrl
: 'Not a file path'
472 url
: '/a/a0/blah blah blah',
473 typeOfUrl
: 'Space characters'
477 for ( i
= 0; i
< cases
.length
; i
++ ) {
478 thisCase
= cases
[ i
];
479 title
= mw
.Title
.newFromImg( { src
: thisCase
.url
} );
481 if ( thisCase
.nameText
!== undefined ) {
482 prefix
= '[' + thisCase
.typeOfUrl
+ ' URL' + '] ';
484 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
485 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
486 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
487 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
489 assert
.strictEqual( title
, null, thisCase
.typeOfUrl
+ ', should not produce an mw.Title object' );
494 QUnit
.test( 'getRelativeText', 5, function ( assert
) {
495 var i
, thisCase
, title
,
500 expectedResult
: ':Asd'
505 expectedResult
: 'Dfg'
508 text
: 'Template:Ghj',
510 expectedResult
: 'Template:Ghj'
520 expectedResult
: 'User:Hi'
524 for ( i
= 0; i
< cases
.length
; i
++ ) {
525 thisCase
= cases
[ i
];
527 title
= mw
.Title
.newFromText( thisCase
.text
);
528 assert
.equal( title
.getRelativeText( thisCase
.relativeTo
), thisCase
.expectedResult
);
532 QUnit
.test( 'normalizeExtension', 5, function ( assert
) {
533 var extension
, i
, thisCase
, prefix
,
538 description
: 'Extension already in canonical form'
543 description
: 'Extension lowercased in canonical form'
548 description
: 'Extension changed in canonical form'
553 description
: 'Extension lowercased and changed in canonical form'
558 description
: 'Extension invalid and discarded'
562 for ( i
= 0; i
< cases
.length
; i
++ ) {
563 thisCase
= cases
[ i
];
564 extension
= mw
.Title
.normalizeExtension( thisCase
.extension
);
566 prefix
= '[' + thisCase
.description
+ '] ';
567 assert
.equal( extension
, thisCase
.expected
, prefix
+ 'Extension as expected' );
571 QUnit
.test( 'newFromUserInput', 12, function ( assert
) {
572 var title
, i
, thisCase
, prefix
,
575 title
: 'DCS0001557854455.JPG',
576 expected
: 'DCS0001557854455.JPG',
577 description
: 'Title in normal namespace without anything invalid but with "file extension"'
580 title
: 'MediaWiki:Msg-awesome',
581 expected
: 'MediaWiki:Msg-awesome',
582 description
: 'Full title (page in MediaWiki namespace) supplied as string'
585 title
: 'The/Mw/Sound.flac',
586 defaultNamespace
: -2,
587 expected
: 'Media:The-Mw-Sound.flac',
588 description
: 'Page in Media-namespace without explicit options'
591 title
: 'File:The/Mw/Sound.kml',
596 expected
: 'File:The/Mw/Sound.kml',
597 description
: 'Page in File-namespace without explicit options'
600 title
: 'File:Foo.JPEG',
601 expected
: 'File:Foo.JPEG',
602 description
: 'Page in File-namespace with non-canonical extension'
605 title
: 'File:Foo.JPEG ',
606 expected
: 'File:Foo.JPEG',
607 description
: 'Page in File-namespace with trailing whitespace'
611 for ( i
= 0; i
< cases
.length
; i
++ ) {
612 thisCase
= cases
[ i
];
613 title
= mw
.Title
.newFromUserInput( thisCase
.title
, thisCase
.defaultNamespace
, thisCase
.options
);
615 if ( thisCase
.expected
!== undefined ) {
616 prefix
= '[' + thisCase
.description
+ '] ';
618 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
619 assert
.equal( title
.toText(), thisCase
.expected
, prefix
+ 'Title as expected' );
621 assert
.strictEqual( title
, null, thisCase
.description
+ ', should not produce an mw.Title object' );
626 QUnit
.test( 'newFromFileName', 54, function ( assert
) {
627 var title
, i
, thisCase
, prefix
,
630 fileName
: 'DCS0001557854455.JPG',
631 typeOfName
: 'Standard camera output',
632 nameText
: 'DCS0001557854455',
633 prefixedText
: 'File:DCS0001557854455.JPG'
636 fileName
: 'File:Sample.png',
637 typeOfName
: 'Carrying namespace',
638 nameText
: 'File-Sample',
639 prefixedText
: 'File:File-Sample.png'
642 fileName
: 'Treppe 2222 Test upload.jpg',
643 typeOfName
: 'File name with spaces in it and lower case file extension',
644 nameText
: 'Treppe 2222 Test upload',
645 prefixedText
: 'File:Treppe 2222 Test upload.jpg'
648 fileName
: 'I contain a \ttab.jpg',
649 typeOfName
: 'Name containing a tab character',
650 nameText
: 'I contain a tab',
651 prefixedText
: 'File:I contain a tab.jpg'
654 fileName
: 'I_contain multiple__ ___ _underscores.jpg',
655 typeOfName
: 'Name containing multiple underscores',
656 nameText
: 'I contain multiple underscores',
657 prefixedText
: 'File:I contain multiple underscores.jpg'
660 fileName
: 'I like ~~~~~~~~es.jpg',
661 typeOfName
: 'Name containing more than three consecutive tilde characters',
662 nameText
: 'I like ~~es',
663 prefixedText
: 'File:I like ~~es.jpg'
666 fileName
: 'BI\u200EDI.jpg',
667 typeOfName
: 'Name containing BIDI overrides',
669 prefixedText
: 'File:BIDI.jpg'
672 fileName
: '100%ab progress.jpg',
673 typeOfName
: 'File name with URL encoding',
674 nameText
: '100% ab progress',
675 prefixedText
: 'File:100% ab progress.jpg'
678 fileName
: '<([>]):/#.jpg',
679 typeOfName
: 'File name with characters not permitted in titles that are replaced',
680 nameText
: '((()))---',
681 prefixedText
: 'File:((()))---.jpg'
684 fileName
: 'spaces\u0009\u2000\u200A\u200Bx.djvu',
685 typeOfName
: 'File name with different kind of spaces',
686 nameText
: 'Spaces \u200Bx',
687 prefixedText
: 'File:Spaces \u200Bx.djvu'
690 fileName
: 'dot.dot.dot.dot.dotdot',
691 typeOfName
: 'File name with a lot of dots',
692 nameText
: 'Dot.dot.dot.dot',
693 prefixedText
: 'File:Dot.dot.dot.dot.dotdot'
696 fileName
: 'dot. dot ._dot',
697 typeOfName
: 'File name with multiple dots and spaces',
698 nameText
: 'Dot. dot',
699 prefixedText
: 'File:Dot. dot. dot'
702 fileName
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂.png',
703 typeOfName
: 'File name longer than 240 bytes',
704 nameText
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵',
705 prefixedText
: 'File:𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵.png'
709 typeOfName
: 'Empty string'
713 typeOfName
: 'String with only alphabet characters'
717 for ( i
= 0; i
< cases
.length
; i
++ ) {
718 thisCase
= cases
[ i
];
719 title
= mw
.Title
.newFromFileName( thisCase
.fileName
);
721 if ( thisCase
.nameText
!== undefined ) {
722 prefix
= '[' + thisCase
.typeOfName
+ '] ';
724 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
725 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
726 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
727 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
729 assert
.strictEqual( title
, null, thisCase
.typeOfName
+ ', should not produce an mw.Title object' );
734 }( mediaWiki
, jQuery
) );