mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-19 05:15:52 +00:00
642bdf013e
This is needed for wikis that use LanguageConverter, since the title attribute is converted to the user's variant, and the canonical title is needed for the API unless converttitles is specified. For filtering, instead of comparing linkHref and expectedHref, filter out links that have other query parameters or aren't in content namespaces. Bug: T93605 Change-Id: I5534753307ed5e1d4b27c52c616fd143b2a397e1
34 lines
851 B
JavaScript
34 lines
851 B
JavaScript
( function ( $, mw ) {
|
|
|
|
QUnit.module( 'ext.popups.core', QUnit.newMwEnvironment( {
|
|
config: {
|
|
wgArticlePath: '/wiki/$1'
|
|
}
|
|
} ) );
|
|
|
|
QUnit.test( 'getTitle', function ( assert ) {
|
|
var cases, i, expected, actual;
|
|
|
|
QUnit.expect( 10 );
|
|
cases = [
|
|
[ '/wiki/Foo', 'Foo' ],
|
|
[ '/wiki/Foo#Bar', 'Foo' ],
|
|
[ '/wiki/Foo?oldid=1', undefined ],
|
|
[ '/wiki/%E6%B8%AC%E8%A9%A6', '測試' ],
|
|
[ '/w/index.php?title=Foo', 'Foo' ],
|
|
[ '/w/index.php?title=Foo#Bar', 'Foo' ],
|
|
[ '/w/Foo?title=Foo&action=edit', undefined ],
|
|
[ '/w/index.php?title=%E6%B8%AC%E8%A9%A6', '測試' ],
|
|
[ '/w/index.php?oldid=1', undefined ],
|
|
[ '/Foo', undefined ]
|
|
];
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
expected = cases[i][1];
|
|
actual = mw.popups.getTitle( cases[i][0] );
|
|
assert.equal( actual, expected );
|
|
}
|
|
} );
|
|
|
|
} ) ( jQuery, mediaWiki );
|