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
45 // XML/HTML character entity references
46 // Note: The ones with # are commented out as those are interpreted as fragment and
47 // as such end up being valid.
51 // Subject of NS_TALK does not roundtrip to NS_MAIN
52 'Talk:File:Example.svg',
53 // Directory navigation
67 // Extension separation is a js invention, for length
68 // purposes it is part of the title
69 repeat( 'x', 252 ) + '.json',
70 // Namespace prefix without actual title
77 QUnit
.module( 'mediawiki.Title', QUnit
.newMwEnvironment( {
78 // mw.Title relies on these three config vars
79 // Restore them after each test run
81 wgFormattedNamespaces
: {
100 // testing custom / localized namespace
103 // jscs: disable requireCamelCaseOrUpperCaseIdentifiers
127 // Testing custom namespaces and aliases
129 antarctic_waterfowl
: 100
131 // jscs: enable requireCamelCaseOrUpperCaseIdentifiers
132 wgCaseSensitiveNamespaces
: []
136 QUnit
.test( 'constructor', cases
.invalid
.length
, function ( assert
) {
138 for ( i
= 0; i
< cases
.valid
.length
; i
++ ) {
139 title
= new mw
.Title( cases
.valid
[ i
] );
141 for ( i
= 0; i
< cases
.invalid
.length
; i
++ ) {
142 /*jshint loopfunc:true */
143 title
= cases
.invalid
[ i
];
144 assert
.throws( function () {
145 return new mw
.Title( title
);
146 }, cases
.invalid
[ i
] );
150 QUnit
.test( 'newFromText', cases
.valid
.length
+ cases
.invalid
.length
, function ( assert
) {
152 for ( i
= 0; i
< cases
.valid
.length
; i
++ ) {
154 $.type( mw
.Title
.newFromText( cases
.valid
[ i
] ) ),
159 for ( i
= 0; i
< cases
.invalid
.length
; i
++ ) {
161 $.type( mw
.Title
.newFromText( cases
.invalid
[ i
] ) ),
168 QUnit
.test( 'Basic parsing', 21, function ( assert
) {
170 title
= new mw
.Title( 'File:Foo_bar.JPG' );
172 assert
.equal( title
.getNamespaceId(), 6 );
173 assert
.equal( title
.getNamespacePrefix(), 'File:' );
174 assert
.equal( title
.getName(), 'Foo_bar' );
175 assert
.equal( title
.getNameText(), 'Foo bar' );
176 assert
.equal( title
.getExtension(), 'JPG' );
177 assert
.equal( title
.getDotExtension(), '.JPG' );
178 assert
.equal( title
.getMain(), 'Foo_bar.JPG' );
179 assert
.equal( title
.getMainText(), 'Foo bar.JPG' );
180 assert
.equal( title
.getPrefixedDb(), 'File:Foo_bar.JPG' );
181 assert
.equal( title
.getPrefixedText(), 'File:Foo bar.JPG' );
183 title
= new mw
.Title( 'Foo#bar' );
184 assert
.equal( title
.getPrefixedText(), 'Foo' );
185 assert
.equal( title
.getFragment(), 'bar' );
187 title
= new mw
.Title( '.foo' );
188 assert
.equal( title
.getPrefixedText(), '.foo' );
189 assert
.equal( title
.getName(), '' );
190 assert
.equal( title
.getNameText(), '' );
191 assert
.equal( title
.getExtension(), 'foo' );
192 assert
.equal( title
.getDotExtension(), '.foo' );
193 assert
.equal( title
.getMain(), '.foo' );
194 assert
.equal( title
.getMainText(), '.foo' );
195 assert
.equal( title
.getPrefixedDb(), '.foo' );
196 assert
.equal( title
.getPrefixedText(), '.foo' );
199 QUnit
.test( 'Transformation', 11, function ( assert
) {
202 title
= new mw
.Title( 'File:quux pif.jpg' );
203 assert
.equal( title
.getNameText(), 'Quux pif', 'First character of title' );
205 title
= new mw
.Title( 'File:Glarg_foo_glang.jpg' );
206 assert
.equal( title
.getNameText(), 'Glarg foo glang', 'Underscores' );
208 title
= new mw
.Title( 'User:ABC.DEF' );
209 assert
.equal( title
.toText(), 'User:ABC.DEF', 'Round trip text' );
210 assert
.equal( title
.getNamespaceId(), 2, 'Parse canonical namespace prefix' );
212 title
= new mw
.Title( 'Image:quux pix.jpg' );
213 assert
.equal( title
.getNamespacePrefix(), 'File:', 'Transform alias to canonical namespace' );
215 title
= new mw
.Title( 'uSEr:hAshAr' );
216 assert
.equal( title
.toText(), 'User:HAshAr' );
217 assert
.equal( title
.getNamespaceId(), 2, 'Case-insensitive namespace prefix' );
219 // Don't ask why, it's the way the backend works. One space is kept of each set.
220 title
= new mw
.Title( 'Foo __ \t __ bar' );
221 assert
.equal( title
.getMain(), 'Foo_bar', 'Merge multiple types of whitespace/underscores into a single underscore' );
223 // Regression test: Previously it would only detect an extension if there is no space after it
224 title
= new mw
.Title( 'Example.js ' );
225 assert
.equal( title
.getExtension(), 'js', 'Space after an extension is stripped' );
227 title
= new mw
.Title( 'Example#foo' );
228 assert
.equal( title
.getFragment(), 'foo', 'Fragment' );
230 title
= new mw
.Title( 'Example#_foo_bar baz_' );
231 assert
.equal( title
.getFragment(), ' foo bar baz', 'Fragment' );
234 QUnit
.test( 'Namespace detection and conversion', 10, function ( assert
) {
237 title
= new mw
.Title( 'File:User:Example' );
238 assert
.equal( title
.getNamespaceId(), 6, 'Titles can contain namespace prefixes, which are otherwise ignored' );
240 title
= new mw
.Title( 'Example', 6 );
241 assert
.equal( title
.getNamespaceId(), 6, 'Default namespace passed is used' );
243 title
= new mw
.Title( 'User:Example', 6 );
244 assert
.equal( title
.getNamespaceId(), 2, 'Included namespace prefix overrides the given default' );
246 title
= new mw
.Title( ':Example', 6 );
247 assert
.equal( title
.getNamespaceId(), 0, 'Colon forces main namespace' );
249 title
= new mw
.Title( 'something.PDF', 6 );
250 assert
.equal( title
.toString(), 'File:Something.PDF' );
252 title
= new mw
.Title( 'NeilK', 3 );
253 assert
.equal( title
.toString(), 'User_talk:NeilK' );
254 assert
.equal( title
.toText(), 'User talk:NeilK' );
256 title
= new mw
.Title( 'Frobisher', 100 );
257 assert
.equal( title
.toString(), 'Penguins:Frobisher' );
259 title
= new mw
.Title( 'antarctic_waterfowl:flightless_yet_cute.jpg' );
260 assert
.equal( title
.toString(), 'Penguins:Flightless_yet_cute.jpg' );
262 title
= new mw
.Title( 'Penguins:flightless_yet_cute.jpg' );
263 assert
.equal( title
.toString(), 'Penguins:Flightless_yet_cute.jpg' );
266 QUnit
.test( 'Throw error on invalid title', 1, function ( assert
) {
267 assert
.throws( function () {
268 return new mw
.Title( '' );
269 }, 'Throw error on empty string' );
272 QUnit
.test( 'Case-sensivity', 3, function ( assert
) {
276 mw
.config
.set( 'wgCaseSensitiveNamespaces', [] );
278 title
= new mw
.Title( 'article' );
279 assert
.equal( title
.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
281 // $wgCapitalLinks = false;
282 mw
.config
.set( 'wgCaseSensitiveNamespaces', [ 0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15 ] );
284 title
= new mw
.Title( 'article' );
285 assert
.equal( title
.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
287 title
= new mw
.Title( 'john', 2 );
288 assert
.equal( title
.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
291 QUnit
.test( 'toString / toText', 2, function ( assert
) {
292 var title
= new mw
.Title( 'Some random page' );
294 assert
.equal( title
.toString(), title
.getPrefixedDb() );
295 assert
.equal( title
.toText(), title
.getPrefixedText() );
298 QUnit
.test( 'getExtension', 7, function ( assert
) {
299 function extTest( pagename
, ext
, description
) {
300 var title
= new mw
.Title( pagename
);
301 assert
.equal( title
.getExtension(), ext
, description
|| pagename
);
304 extTest( 'MediaWiki:Vector.js', 'js' );
305 extTest( 'User:Example/common.css', 'css' );
306 extTest( 'File:Example.longextension', 'longextension', 'Extension parsing not limited (bug 36151)' );
307 extTest( 'Example/information.json', 'json', 'Extension parsing not restricted from any namespace' );
308 extTest( 'Foo.', null, 'Trailing dot is not an extension' );
309 extTest( 'Foo..', null, 'Trailing dots are not an extension' );
310 extTest( 'Foo.a.', null, 'Page name with dots and ending in a dot does not have an extension' );
312 // @broken: Throws an exception
313 // extTest( '.NET', null, 'Leading dot is (or is not?) an extension' );
316 QUnit
.test( 'exists', 3, function ( assert
) {
319 // Empty registry, checks default to null
321 title
= new mw
.Title( 'Some random page', 4 );
322 assert
.strictEqual( title
.exists(), null, 'Return null with empty existance registry' );
324 // Basic registry, checks default to boolean
325 mw
.Title
.exist
.set( [ 'Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules' ], true );
326 mw
.Title
.exist
.set( [ 'Does_not_exist', 'User:John', 'Foobar' ], false );
328 title
= new mw
.Title( 'Project:Sandbox rules' );
329 assert
.assertTrue( title
.exists(), 'Return true for page titles marked as existing' );
330 title
= new mw
.Title( 'Foobar' );
331 assert
.assertFalse( title
.exists(), 'Return false for page titles marked as nonexistent' );
335 QUnit
.test( 'getUrl', 4, function ( assert
) {
339 mw
.config
.set( 'wgArticlePath', '/wiki/$1' );
341 title
= new mw
.Title( 'Foobar' );
342 assert
.equal( title
.getUrl(), '/wiki/Foobar', 'Basic functionality, getUrl uses mw.util.getUrl' );
343 assert
.equal( title
.getUrl( { action
: 'edit' } ), '/wiki/Foobar?action=edit', 'Basic functionality, \'params\' parameter' );
345 title
= new mw
.Title( 'John Doe', 3 );
346 assert
.equal( title
.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
348 title
= new mw
.Title( 'John Cena#And_His_Name_Is', 3 );
349 assert
.equal( title
.getUrl( { meme
: true } ), '/wiki/User_talk:John_Cena?meme=true#And_His_Name_Is', 'title with fragment and query parameter' );
352 QUnit
.test( 'newFromImg', 44, function ( assert
) {
353 var title
, i
, thisCase
, prefix
,
356 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',
357 typeOfUrl
: 'Hashed thumb with shortened path',
358 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)',
359 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'
363 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',
364 typeOfUrl
: 'Hashed thumb with sha1-ed path',
365 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)',
366 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'
370 url
: '/wiki/images/thumb/9/91/Anticlockwise_heliotrope%27s.jpg/99px-Anticlockwise_heliotrope%27s.jpg',
371 typeOfUrl
: 'Normal hashed directory thumbnail',
372 nameText
: 'Anticlockwise heliotrope\'s',
373 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
377 url
: '/wiki/images/thumb/8/80/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
378 typeOfUrl
: 'Normal hashed directory thumbnail with complex thumbnail parameters',
379 nameText
: 'Wikipedia-logo-v2',
380 prefixedText
: 'File:Wikipedia-logo-v2.svg'
384 url
: '//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
385 typeOfUrl
: 'Commons thumbnail',
386 nameText
: 'Wikipedia-logo-v2',
387 prefixedText
: 'File:Wikipedia-logo-v2.svg'
391 url
: '/wiki/images/9/91/Anticlockwise_heliotrope%27s.jpg',
392 typeOfUrl
: 'Full image',
393 nameText
: 'Anticlockwise heliotrope\'s',
394 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
398 url
: 'http://localhost/thumb.php?f=Stuffless_Figaro%27s.jpg&width=180',
399 typeOfUrl
: 'thumb.php-based thumbnail',
400 nameText
: 'Stuffless Figaro\'s',
401 prefixedText
: 'File:Stuffless Figaro\'s.jpg'
405 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
406 typeOfUrl
: 'Commons unhashed thumbnail',
407 nameText
: 'Wikipedia-logo-v2',
408 prefixedText
: 'File:Wikipedia-logo-v2.svg'
412 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
413 typeOfUrl
: 'Commons unhashed thumbnail with complex thumbnail parameters',
414 nameText
: 'Wikipedia-logo-v2',
415 prefixedText
: 'File:Wikipedia-logo-v2.svg'
419 url
: '/wiki/images/Anticlockwise_heliotrope%27s.jpg',
420 typeOfUrl
: 'Unhashed local file',
421 nameText
: 'Anticlockwise heliotrope\'s',
422 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
427 typeOfUrl
: 'Empty string'
432 typeOfUrl
: 'String with only alphabet characters'
436 url
: 'foobar.foobar',
437 typeOfUrl
: 'Not a file path'
441 url
: '/a/a0/blah blah blah',
442 typeOfUrl
: 'Space characters'
446 for ( i
= 0; i
< cases
.length
; i
++ ) {
447 thisCase
= cases
[ i
];
448 title
= mw
.Title
.newFromImg( { src
: thisCase
.url
} );
450 if ( thisCase
.nameText
!== undefined ) {
451 prefix
= '[' + thisCase
.typeOfUrl
+ ' URL' + '] ';
453 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
454 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
455 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
456 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
458 assert
.strictEqual( title
, null, thisCase
.typeOfUrl
+ ', should not produce an mw.Title object' );
463 QUnit
.test( 'getRelativeText', 5, function ( assert
) {
464 var i
, thisCase
, title
,
469 expectedResult
: ':Asd'
474 expectedResult
: 'Dfg'
477 text
: 'Template:Ghj',
479 expectedResult
: 'Template:Ghj'
489 expectedResult
: 'User:Hi'
493 for ( i
= 0; i
< cases
.length
; i
++ ) {
494 thisCase
= cases
[ i
];
496 title
= mw
.Title
.newFromText( thisCase
.text
);
497 assert
.equal( title
.getRelativeText( thisCase
.relativeTo
), thisCase
.expectedResult
);
501 QUnit
.test( 'normalizeExtension', 5, function ( assert
) {
502 var extension
, i
, thisCase
, prefix
,
507 description
: 'Extension already in canonical form'
512 description
: 'Extension lowercased in canonical form'
517 description
: 'Extension changed in canonical form'
522 description
: 'Extension lowercased and changed in canonical form'
527 description
: 'Extension invalid and discarded'
531 for ( i
= 0; i
< cases
.length
; i
++ ) {
532 thisCase
= cases
[ i
];
533 extension
= mw
.Title
.normalizeExtension( thisCase
.extension
);
535 prefix
= '[' + thisCase
.description
+ '] ';
536 assert
.equal( extension
, thisCase
.expected
, prefix
+ 'Extension as expected' );
540 QUnit
.test( 'newFromUserInput', 12, function ( assert
) {
541 var title
, i
, thisCase
, prefix
,
544 title
: 'DCS0001557854455.JPG',
545 expected
: 'DCS0001557854455.JPG',
546 description
: 'Title in normal namespace without anything invalid but with "file extension"'
549 title
: 'MediaWiki:Msg-awesome',
550 expected
: 'MediaWiki:Msg-awesome',
551 description
: 'Full title (page in MediaWiki namespace) supplied as string'
554 title
: 'The/Mw/Sound.flac',
555 defaultNamespace
: -2,
556 expected
: 'Media:The-Mw-Sound.flac',
557 description
: 'Page in Media-namespace without explicit options'
560 title
: 'File:The/Mw/Sound.kml',
565 expected
: 'File:The/Mw/Sound.kml',
566 description
: 'Page in File-namespace without explicit options'
569 title
: 'File:Foo.JPEG',
570 expected
: 'File:Foo.JPEG',
571 description
: 'Page in File-namespace with non-canonical extension'
574 title
: 'File:Foo.JPEG ',
575 expected
: 'File:Foo.JPEG',
576 description
: 'Page in File-namespace with trailing whitespace'
580 for ( i
= 0; i
< cases
.length
; i
++ ) {
581 thisCase
= cases
[ i
];
582 title
= mw
.Title
.newFromUserInput( thisCase
.title
, thisCase
.defaultNamespace
, thisCase
.options
);
584 if ( thisCase
.expected
!== undefined ) {
585 prefix
= '[' + thisCase
.description
+ '] ';
587 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
588 assert
.equal( title
.toText(), thisCase
.expected
, prefix
+ 'Title as expected' );
590 assert
.strictEqual( title
, null, thisCase
.description
+ ', should not produce an mw.Title object' );
595 QUnit
.test( 'newFromFileName', 54, function ( assert
) {
596 var title
, i
, thisCase
, prefix
,
599 fileName
: 'DCS0001557854455.JPG',
600 typeOfName
: 'Standard camera output',
601 nameText
: 'DCS0001557854455',
602 prefixedText
: 'File:DCS0001557854455.JPG'
605 fileName
: 'File:Sample.png',
606 typeOfName
: 'Carrying namespace',
607 nameText
: 'File-Sample',
608 prefixedText
: 'File:File-Sample.png'
611 fileName
: 'Treppe 2222 Test upload.jpg',
612 typeOfName
: 'File name with spaces in it and lower case file extension',
613 nameText
: 'Treppe 2222 Test upload',
614 prefixedText
: 'File:Treppe 2222 Test upload.jpg'
617 fileName
: 'I contain a \ttab.jpg',
618 typeOfName
: 'Name containing a tab character',
619 nameText
: 'I contain a tab',
620 prefixedText
: 'File:I contain a tab.jpg'
623 fileName
: 'I_contain multiple__ ___ _underscores.jpg',
624 typeOfName
: 'Name containing multiple underscores',
625 nameText
: 'I contain multiple underscores',
626 prefixedText
: 'File:I contain multiple underscores.jpg'
629 fileName
: 'I like ~~~~~~~~es.jpg',
630 typeOfName
: 'Name containing more than three consecutive tilde characters',
631 nameText
: 'I like ~~es',
632 prefixedText
: 'File:I like ~~es.jpg'
635 fileName
: 'BI\u200EDI.jpg',
636 typeOfName
: 'Name containing BIDI overrides',
638 prefixedText
: 'File:BIDI.jpg'
641 fileName
: '100%ab progress.jpg',
642 typeOfName
: 'File name with URL encoding',
643 nameText
: '100% ab progress',
644 prefixedText
: 'File:100% ab progress.jpg'
647 fileName
: '<([>]):/#.jpg',
648 typeOfName
: 'File name with characters not permitted in titles that are replaced',
649 nameText
: '((()))---',
650 prefixedText
: 'File:((()))---.jpg'
653 fileName
: 'spaces\u0009\u2000\u200A\u200Bx.djvu',
654 typeOfName
: 'File name with different kind of spaces',
655 nameText
: 'Spaces \u200Bx',
656 prefixedText
: 'File:Spaces \u200Bx.djvu'
659 fileName
: 'dot.dot.dot.dot.dotdot',
660 typeOfName
: 'File name with a lot of dots',
661 nameText
: 'Dot.dot.dot.dot',
662 prefixedText
: 'File:Dot.dot.dot.dot.dotdot'
665 fileName
: 'dot. dot ._dot',
666 typeOfName
: 'File name with multiple dots and spaces',
667 nameText
: 'Dot. dot',
668 prefixedText
: 'File:Dot. dot. dot'
671 fileName
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂.png',
672 typeOfName
: 'File name longer than 240 bytes',
673 nameText
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵',
674 prefixedText
: 'File:𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵.png'
678 typeOfName
: 'Empty string'
682 typeOfName
: 'String with only alphabet characters'
686 for ( i
= 0; i
< cases
.length
; i
++ ) {
687 thisCase
= cases
[ i
];
688 title
= mw
.Title
.newFromFileName( thisCase
.fileName
);
690 if ( thisCase
.nameText
!== undefined ) {
691 prefix
= '[' + thisCase
.typeOfName
+ '] ';
693 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
694 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
695 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
696 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
698 assert
.strictEqual( title
, null, thisCase
.typeOfName
+ ', should not produce an mw.Title object' );
703 }( mediaWiki
, jQuery
) );