From c68aede585779a17a1b35e3f9de3594fd2407fbb Mon Sep 17 00:00:00 2001 From: Krinkle Date: Sat, 10 Sep 2011 22:33:11 +0000 Subject: [PATCH] mediawiki.Title.test: Add test for space collapsing * 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. --- .../suites/resources/mediawiki/mediawiki.Title.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js index 157db4d72f..cda44a8d51 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js @@ -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() { -- 2.20.1