mediawiki.Title: Remove dead code and streamline newFromUserInput()
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.Title.test.js
index 4a32157..a3f3cc8 100644 (file)
        } );
 
        QUnit.test( 'wantSignaturesNamespace', function ( assert ) {
-               var namespaces = mw.config.values.wgExtraSignatureNamespaces;
-
-               mw.config.values.wgExtraSignatureNamespaces = [];
+               mw.config.set( 'wgExtraSignatureNamespaces', [] );
                assert.strictEqual( mw.Title.wantSignaturesNamespace( 0 ), false, 'Main namespace has no signatures' );
                assert.strictEqual( mw.Title.wantSignaturesNamespace( 1 ), true, 'Talk namespace has signatures' );
                assert.strictEqual( mw.Title.wantSignaturesNamespace( 2 ), false, 'NS2 has no signatures' );
                assert.strictEqual( mw.Title.wantSignaturesNamespace( 3 ), true, 'NS3 has signatures' );
 
-               mw.config.values.wgExtraSignatureNamespaces = [ 0 ];
+               mw.config.set( 'wgExtraSignatureNamespaces', [ 0 ] );
                assert.strictEqual( mw.Title.wantSignaturesNamespace( 0 ), true, 'Main namespace has signatures when explicitly defined' );
-
-               // Restore
-               mw.config.values.wgExtraSignatureNamespaces = namespaces;
        } );
 
        QUnit.test( 'Throw error on invalid title', function ( assert ) {
                                        title: 'File:Foo.JPEG  ',
                                        expected: 'File:Foo.JPEG',
                                        description: 'Page in File-namespace with trailing whitespace'
+                               },
+                               {
+                                       title: 'File:Foo',
+                                       description: 'File name without file extension'
+                               },
+                               {
+                                       title: 'File:Foo.',
+                                       description: 'File name with empty file extension'
                                }
                        ];
 
 
                                assert.notStrictEqual( title, null, prefix + 'Parses successfully' );
                                assert.strictEqual( title.toText(), thisCase.expected, prefix + 'Title as expected' );
+                               if ( thisCase.defaultNamespace === undefined ) {
+                                       title = mw.Title.newFromUserInput( thisCase.title, thisCase.options );
+                                       assert.strictEqual( title.toText(), thisCase.expected, prefix + 'Skipping namespace argument' );
+                               }
                        } else {
                                assert.strictEqual( title, null, thisCase.description + ', should not produce an mw.Title object' );
                        }