' ),
$processedLinks;
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 ],
/*jshint -W107 */
[ 'javascript:void(0);', undefined ],
/*jshint +W107 */
[ 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', undefined ]
];
$.each( cases, function ( _, testCase ) {
$( '
', {
href: testCase[0],
title: 'link title'
} ).appendTo( $container );
} );
$processedLinks = mw.popups.processLinks( $container, this.blacklist, this.config );
// Now let's make some assertions!
cases = $.grep( cases, function ( testCase ) {
return testCase[1];
} );
QUnit.expect( cases.length + 1 );
assert.strictEqual(
$processedLinks.length,
cases.length,
'Links with titles that can\'t be extracted are filtered.'
);
$.each( cases, function ( i, testCase ) {
assert.strictEqual(
$processedLinks.eq( i ).data( 'previews-page-title' ),
testCase[1]
);
} );
} );
}( mediaWiki, jQuery ) );