r93519 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93518‎ | r93519 | r93520 >
Date:08:08, 30 July 2011
Author:krinkle
Status:ok
Tags:
Comment:
Increasing coverage of mw.Title with unit tests.

* QUnit Completeness Test – Before:
Title.prototype.getNamespaceId
Title.prototype.getPrefixedText
Title.prototype.getExtension
Title.prototype.setNameAndExtension
Title.prototype.getUrl
Title.prototype.exists

* QUnit Completeness Test – After:
Title.prototype.getNamespaceId
Title.prototype.getPrefixedText
Title.prototype.getExtension
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js
@@ -134,3 +134,63 @@
135135 title.setNamespace( 'Entirely Unknown' );
136136 });
137137 });
 138+
 139+test( 'Case-sensivity', function() {
 140+ expect(3);
 141+ _titleConfig();
 142+
 143+ var title;
 144+
 145+ // Default config
 146+ mw.config.set( 'wgCaseSensitiveNamespaces', [] );
 147+
 148+ title = new mw.Title( 'article' );
 149+ equal( title.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
 150+
 151+ // $wgCapitalLinks = false;
 152+ mw.config.set( 'wgCaseSensitiveNamespaces', [0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15] );
 153+
 154+ title = new mw.Title( 'article' );
 155+ equal( title.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
 156+
 157+ title = new mw.Title( 'john', 2 );
 158+ equal( title.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
 159+});
 160+
 161+test( 'Exists', function() {
 162+ expect(3);
 163+ _titleConfig();
 164+
 165+ var title;
 166+
 167+ // Empty registry, checks default to null
 168+
 169+ title = new mw.Title( 'Some random page', 4 );
 170+ strictEqual( title.exists(), null, 'Return null with empty existance registry' );
 171+
 172+ // Basic registry, checks default to boolean
 173+ mw.Title.exist.set( ['Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules'], true );
 174+ mw.Title.exist.set( ['Does_not_exist', 'User:John', 'Foobar'], false );
 175+
 176+ title = new mw.Title( 'Project:Sandbox rules' );
 177+ assertTrue( title.exists(), 'Return true for page titles marked as existing' );
 178+ title = new mw.Title( 'Foobar' );
 179+ assertFalse( title.exists(), 'Return false for page titles marked as inexisting' );
 180+
 181+});
 182+
 183+test( 'Url', function() {
 184+ expect(2);
 185+ _titleConfig();
 186+
 187+ var title;
 188+
 189+ // Config
 190+ mw.config.set( 'wgArticlePath', '/wiki/$1' );
 191+
 192+ title = new mw.Title( 'Foobar' );
 193+ equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, toString passing to wikiGetlink' );
 194+
 195+ title = new mw.Title( 'John Doe', 3 );
 196+ equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
 197+});
\ No newline at end of file

Status & tagging log