mediawiki.Title.test: Add test for space collapsing
authorKrinkle <krinkle@users.mediawiki.org>
Sat, 10 Sep 2011 22:33:11 +0000 (22:33 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sat, 10 Sep 2011 22:33:11 +0000 (22:33 +0000)
* When I first passed "Foobar___.js" to mw.Title and saw that it was stripping away (some) spaces, I thought it was a bug (since extension is part of the title and should be kept as is). Anyway, as it turns out it's not stripping them away because they are between 'title' and 'extension', it's a general rule that there should not two or more spaces next to each other in a title. Adding test to assert and confirm this behavior.

tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js

index 157db4d..cda44a8 100644 (file)
@@ -63,8 +63,8 @@ test( '-- Initial check', function() {
        ok( mw.Title, 'mw.Title defined' );
 });
 
-test( 'Transform between Text and Db', function() {
-       expect(2);
+test( 'Transformation', function() {
+       expect(3);
        _titleConfig();
 
        var title;
@@ -74,6 +74,10 @@ test( 'Transform between Text and Db', function() {
 
        title = new mw.Title( 'File:Glarg_foo_glang.jpg' );
        equal( title.getNameText(), 'Glarg foo glang' );
+
+       title = new mw.Title( '   MediaWiki:  Foo   bar   .js   ' );
+       // Don't ask why, it's the way the backend works. One space is kept of each set
+       equal( title.getName(), 'Foo_bar_.js', "Merge multiple spaces to a single space." );
 });
 
 test( 'Main text for filename', function() {