r90350 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90349‎ | r90350 | r90351 >
Date:17:44, 18 June 2011
Author:krinkle
Status:ok
Tags:
Comment:
Test suite for mw.Title (Follow-up r90331). Right now it matches the test suite in UploadWizard exactly (converted from jasmin to QUnit)
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js (added) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js
@@ -0,0 +1,136 @@
 2+module( 'mediawiki.Title.js' );
 3+
 4+// mw.Title relies on these three config vars
 5+// Restore them after each test run
 6+var _titleConfig = function() {
 7+
 8+ mw.config.set({
 9+ "wgFormattedNamespaces": {
 10+ "-2": "Media",
 11+ "-1": "Special",
 12+ "0": "",
 13+ "1": "Talk",
 14+ "2": "User",
 15+ "3": "User talk",
 16+ "4": "Wikipedia",
 17+ "5": "Wikipedia talk",
 18+ "6": "File",
 19+ "7": "File talk",
 20+ "8": "MediaWiki",
 21+ "9": "MediaWiki talk",
 22+ "10": "Template",
 23+ "11": "Template talk",
 24+ "12": "Help",
 25+ "13": "Help talk",
 26+ "14": "Category",
 27+ "15": "Category talk",
 28+ /* testing custom / localized */
 29+ "100": "Penguins"
 30+ },
 31+ "wgNamespaceIds": {
 32+ "media": -2,
 33+ "special": -1,
 34+ "": 0,
 35+ "talk": 1,
 36+ "user": 2,
 37+ "user_talk": 3,
 38+ "wikipedia": 4,
 39+ "wikipedia_talk": 5,
 40+ "file": 6,
 41+ "file_talk": 7,
 42+ "mediawiki": 8,
 43+ "mediawiki_talk": 9,
 44+ "template": 10,
 45+ "template_talk": 11,
 46+ "help": 12,
 47+ "help_talk": 13,
 48+ "category": 14,
 49+ "category_talk": 15,
 50+ "image": 6,
 51+ "image_talk": 7,
 52+ "project": 4,
 53+ "project_talk": 5,
 54+ /* testing custom / alias */
 55+ "penguins": 100,
 56+ "antarctic_waterfowl": 100
 57+ },
 58+ "wgCaseSensitiveNamespaces": []
 59+ });
 60+};
 61+
 62+test( '-- Initial check', function() {
 63+ expect(1);
 64+ ok( mw.Title, 'mw.Title defined' );
 65+});
 66+
 67+test( 'Filename', function() {
 68+ expect(4);
 69+ _titleConfig();
 70+
 71+ var title = new mw.Title( 'File:foo_bar.JPG' );
 72+
 73+ equal( title.getMain(), 'Foo_bar.jpg' );
 74+ equal( title.getMainText(), 'Foo bar.jpg' );
 75+ equal( title.getNameText(), 'Foo bar' );
 76+ equal( title.toString(), 'File:Foo_bar.jpg' );
 77+});
 78+
 79+test( 'Transform between Text to Db', function() {
 80+ expect(6);
 81+ _titleConfig();
 82+
 83+ var title = new mw.Title( 'File:foo_bar.JPG' );
 84+ title.setName( 'quux pif' );
 85+
 86+ equal( title.getMain(), 'Quux_pif.jpg' );
 87+ equal( title.getMainText(), 'Quux pif.jpg' );
 88+ equal( title.getNameText(), 'Quux pif' );
 89+ equal( title.toString(), 'File:Quux_pif.jpg' );
 90+
 91+ title.setName( 'glarg_foo_glang' );
 92+
 93+ equal( title.toString(), 'File:Glarg_foo_glang.jpg' );
 94+ equal( title.getMainText(), 'Glarg foo glang.jpg' );
 95+});
 96+
 97+test( 'Initiate from name and set namespace', function() {
 98+ expect(1);
 99+ _titleConfig();
 100+
 101+ var title = new mw.Title( 'catalonian_penguins.PNG' );
 102+ title.setNamespace( 'file' );
 103+ equal( title.toString(), 'File:Catalonian_penguins.png' );
 104+});
 105+
 106+test( 'Namespace detection and conversion', function() {
 107+ expect(7);
 108+ _titleConfig();
 109+
 110+ var title;
 111+
 112+ title = new mw.Title( 'something.PDF' );
 113+ title.setNamespace( 'file' );
 114+ equal( title.toString(), 'File:Something.pdf' );
 115+
 116+ title = new mw.Title( 'NeilK' );
 117+ title.setNamespace( 'user_talk' );
 118+ equal( title.toString(), 'User_talk:NeilK' );
 119+ equal( title.toText(), 'User talk:NeilK' );
 120+
 121+ title = new mw.Title( 'Frobisher' );
 122+ title.setNamespaceById( 100 );
 123+ equal( title.toString(), 'Penguins:Frobisher' );
 124+
 125+ title = new mw.Title( 'flightless_yet_cute.jpg' );
 126+ title.setNamespace( 'antarctic_waterfowl' );
 127+ equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
 128+
 129+ title = new mw.Title( 'flightless_yet_cute.jpg' );
 130+ title.setNamespace( 'Penguins' );
 131+ equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
 132+
 133+ title = new mw.Title( 'flightless_yet_cute.jpg' );
 134+ raises( function() {
 135+ title.setNamespace( 'Entirely Unknown' );
 136+ });
 137+});
Property changes on: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js
___________________________________________________________________
Added: svn:eol-style
1138 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90331Implement mw.Title in core...krinkle09:17, 18 June 2011

Status & tagging log