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', 3, 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' );
349 QUnit
.test( 'newFromImg', 44, function ( assert
) {
350 var title
, i
, thisCase
, prefix
,
353 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',
354 typeOfUrl
: 'Hashed thumb with shortened path',
355 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)',
356 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'
360 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',
361 typeOfUrl
: 'Hashed thumb with sha1-ed path',
362 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)',
363 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'
367 url
: '/wiki/images/thumb/9/91/Anticlockwise_heliotrope%27s.jpg/99px-Anticlockwise_heliotrope%27s.jpg',
368 typeOfUrl
: 'Normal hashed directory thumbnail',
369 nameText
: 'Anticlockwise heliotrope\'s',
370 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
374 url
: '/wiki/images/thumb/8/80/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
375 typeOfUrl
: 'Normal hashed directory thumbnail with complex thumbnail parameters',
376 nameText
: 'Wikipedia-logo-v2',
377 prefixedText
: 'File:Wikipedia-logo-v2.svg'
381 url
: '//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
382 typeOfUrl
: 'Commons thumbnail',
383 nameText
: 'Wikipedia-logo-v2',
384 prefixedText
: 'File:Wikipedia-logo-v2.svg'
388 url
: '/wiki/images/9/91/Anticlockwise_heliotrope%27s.jpg',
389 typeOfUrl
: 'Full image',
390 nameText
: 'Anticlockwise heliotrope\'s',
391 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
395 url
: 'http://localhost/thumb.php?f=Stuffless_Figaro%27s.jpg&width=180',
396 typeOfUrl
: 'thumb.php-based thumbnail',
397 nameText
: 'Stuffless Figaro\'s',
398 prefixedText
: 'File:Stuffless Figaro\'s.jpg'
402 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/150px-Wikipedia-logo-v2.svg.png',
403 typeOfUrl
: 'Commons unhashed thumbnail',
404 nameText
: 'Wikipedia-logo-v2',
405 prefixedText
: 'File:Wikipedia-logo-v2.svg'
409 url
: '/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
410 typeOfUrl
: 'Commons unhashed thumbnail with complex thumbnail parameters',
411 nameText
: 'Wikipedia-logo-v2',
412 prefixedText
: 'File:Wikipedia-logo-v2.svg'
416 url
: '/wiki/images/Anticlockwise_heliotrope%27s.jpg',
417 typeOfUrl
: 'Unhashed local file',
418 nameText
: 'Anticlockwise heliotrope\'s',
419 prefixedText
: 'File:Anticlockwise heliotrope\'s.jpg'
424 typeOfUrl
: 'Empty string'
429 typeOfUrl
: 'String with only alphabet characters'
433 url
: 'foobar.foobar',
434 typeOfUrl
: 'Not a file path'
438 url
: '/a/a0/blah blah blah',
439 typeOfUrl
: 'Space characters'
443 for ( i
= 0; i
< cases
.length
; i
++ ) {
444 thisCase
= cases
[ i
];
445 title
= mw
.Title
.newFromImg( { src
: thisCase
.url
} );
447 if ( thisCase
.nameText
!== undefined ) {
448 prefix
= '[' + thisCase
.typeOfUrl
+ ' URL' + '] ';
450 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
451 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
452 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
453 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
455 assert
.strictEqual( title
, null, thisCase
.typeOfUrl
+ ', should not produce an mw.Title object' );
460 QUnit
.test( 'getRelativeText', 5, function ( assert
) {
461 var i
, thisCase
, title
,
466 expectedResult
: ':Asd'
471 expectedResult
: 'Dfg'
474 text
: 'Template:Ghj',
476 expectedResult
: 'Template:Ghj'
486 expectedResult
: 'User:Hi'
490 for ( i
= 0; i
< cases
.length
; i
++ ) {
491 thisCase
= cases
[ i
];
493 title
= mw
.Title
.newFromText( thisCase
.text
);
494 assert
.equal( title
.getRelativeText( thisCase
.relativeTo
), thisCase
.expectedResult
);
498 QUnit
.test( 'normalizeExtension', 5, function ( assert
) {
499 var extension
, i
, thisCase
, prefix
,
504 description
: 'Extension already in canonical form'
509 description
: 'Extension lowercased in canonical form'
514 description
: 'Extension changed in canonical form'
519 description
: 'Extension lowercased and changed in canonical form'
524 description
: 'Extension invalid and discarded'
528 for ( i
= 0; i
< cases
.length
; i
++ ) {
529 thisCase
= cases
[ i
];
530 extension
= mw
.Title
.normalizeExtension( thisCase
.extension
);
532 prefix
= '[' + thisCase
.description
+ '] ';
533 assert
.equal( extension
, thisCase
.expected
, prefix
+ 'Extension as expected' );
537 QUnit
.test( 'newFromUserInput', 12, function ( assert
) {
538 var title
, i
, thisCase
, prefix
,
541 title
: 'DCS0001557854455.JPG',
542 expected
: 'DCS0001557854455.JPG',
543 description
: 'Title in normal namespace without anything invalid but with "file extension"'
546 title
: 'MediaWiki:Msg-awesome',
547 expected
: 'MediaWiki:Msg-awesome',
548 description
: 'Full title (page in MediaWiki namespace) supplied as string'
551 title
: 'The/Mw/Sound.flac',
552 defaultNamespace
: -2,
553 expected
: 'Media:The-Mw-Sound.flac',
554 description
: 'Page in Media-namespace without explicit options'
557 title
: 'File:The/Mw/Sound.kml',
562 expected
: 'File:The/Mw/Sound.kml',
563 description
: 'Page in File-namespace without explicit options'
566 title
: 'File:Foo.JPEG',
567 expected
: 'File:Foo.JPEG',
568 description
: 'Page in File-namespace with non-canonical extension'
571 title
: 'File:Foo.JPEG ',
572 expected
: 'File:Foo.JPEG',
573 description
: 'Page in File-namespace with trailing whitespace'
577 for ( i
= 0; i
< cases
.length
; i
++ ) {
578 thisCase
= cases
[ i
];
579 title
= mw
.Title
.newFromUserInput( thisCase
.title
, thisCase
.defaultNamespace
, thisCase
.options
);
581 if ( thisCase
.expected
!== undefined ) {
582 prefix
= '[' + thisCase
.description
+ '] ';
584 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
585 assert
.equal( title
.toText(), thisCase
.expected
, prefix
+ 'Title as expected' );
587 assert
.strictEqual( title
, null, thisCase
.description
+ ', should not produce an mw.Title object' );
592 QUnit
.test( 'newFromFileName', 54, function ( assert
) {
593 var title
, i
, thisCase
, prefix
,
596 fileName
: 'DCS0001557854455.JPG',
597 typeOfName
: 'Standard camera output',
598 nameText
: 'DCS0001557854455',
599 prefixedText
: 'File:DCS0001557854455.JPG'
602 fileName
: 'File:Sample.png',
603 typeOfName
: 'Carrying namespace',
604 nameText
: 'File-Sample',
605 prefixedText
: 'File:File-Sample.png'
608 fileName
: 'Treppe 2222 Test upload.jpg',
609 typeOfName
: 'File name with spaces in it and lower case file extension',
610 nameText
: 'Treppe 2222 Test upload',
611 prefixedText
: 'File:Treppe 2222 Test upload.jpg'
614 fileName
: 'I contain a \ttab.jpg',
615 typeOfName
: 'Name containing a tab character',
616 nameText
: 'I contain a tab',
617 prefixedText
: 'File:I contain a tab.jpg'
620 fileName
: 'I_contain multiple__ ___ _underscores.jpg',
621 typeOfName
: 'Name containing multiple underscores',
622 nameText
: 'I contain multiple underscores',
623 prefixedText
: 'File:I contain multiple underscores.jpg'
626 fileName
: 'I like ~~~~~~~~es.jpg',
627 typeOfName
: 'Name containing more than three consecutive tilde characters',
628 nameText
: 'I like ~~es',
629 prefixedText
: 'File:I like ~~es.jpg'
632 fileName
: 'BI\u200EDI.jpg',
633 typeOfName
: 'Name containing BIDI overrides',
635 prefixedText
: 'File:BIDI.jpg'
638 fileName
: '100%ab progress.jpg',
639 typeOfName
: 'File name with URL encoding',
640 nameText
: '100% ab progress',
641 prefixedText
: 'File:100% ab progress.jpg'
644 fileName
: '<([>]):/#.jpg',
645 typeOfName
: 'File name with characters not permitted in titles that are replaced',
646 nameText
: '((()))---',
647 prefixedText
: 'File:((()))---.jpg'
650 fileName
: 'spaces\u0009\u2000\u200A\u200Bx.djvu',
651 typeOfName
: 'File name with different kind of spaces',
652 nameText
: 'Spaces \u200Bx',
653 prefixedText
: 'File:Spaces \u200Bx.djvu'
656 fileName
: 'dot.dot.dot.dot.dotdot',
657 typeOfName
: 'File name with a lot of dots',
658 nameText
: 'Dot.dot.dot.dot',
659 prefixedText
: 'File:Dot.dot.dot.dot.dotdot'
662 fileName
: 'dot. dot ._dot',
663 typeOfName
: 'File name with multiple dots and spaces',
664 nameText
: 'Dot. dot',
665 prefixedText
: 'File:Dot. dot. dot'
668 fileName
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂.png',
669 typeOfName
: 'File name longer than 240 bytes',
670 nameText
: '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵',
671 prefixedText
: 'File:𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵.png'
675 typeOfName
: 'Empty string'
679 typeOfName
: 'String with only alphabet characters'
683 for ( i
= 0; i
< cases
.length
; i
++ ) {
684 thisCase
= cases
[ i
];
685 title
= mw
.Title
.newFromFileName( thisCase
.fileName
);
687 if ( thisCase
.nameText
!== undefined ) {
688 prefix
= '[' + thisCase
.typeOfName
+ '] ';
690 assert
.notStrictEqual( title
, null, prefix
+ 'Parses successfully' );
691 assert
.equal( title
.getNameText(), thisCase
.nameText
, prefix
+ 'Filename matches original' );
692 assert
.equal( title
.getPrefixedText(), thisCase
.prefixedText
, prefix
+ 'File page title matches original' );
693 assert
.equal( title
.getNamespaceId(), 6, prefix
+ 'Namespace ID matches File namespace' );
695 assert
.strictEqual( title
, null, thisCase
.typeOfName
+ ', should not produce an mw.Title object' );
700 }( mediaWiki
, jQuery
) );