mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 10:59:56 +00:00
346216c050
This patch is mostly about the arrow syntax. Some places can not be updated because the arrow syntax also changes the meaning of `this.…`, but some code relies on that. Change-Id: Ida3ab0e0950a428fbd1a85f281013778ee879df4
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface UrlStringTransferHandler tests.
|
|
*
|
|
* @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
QUnit.module( 've.ui.UrlStringTransferHandler (MW)' );
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'paste', ( assert ) => {
|
|
const cases = [
|
|
{
|
|
msg: 'External link converts to internal link',
|
|
pasteString: location.origin + mw.Title.newFromText( 'Main Page' ).getUrl(),
|
|
pasteType: 'text/plain',
|
|
expectedData: () => {
|
|
// Explicitly create an internal link so we can assert this behaviour is working
|
|
const a = ve.dm.MWInternalLinkAnnotation.static.newFromTitle( mw.Title.newFromText( 'Main Page' ) ).element;
|
|
return [
|
|
[ 'M', [ a ] ],
|
|
[ 'a', [ a ] ],
|
|
[ 'i', [ a ] ],
|
|
[ 'n', [ a ] ],
|
|
[ ' ', [ a ] ],
|
|
[ 'P', [ a ] ],
|
|
[ 'a', [ a ] ],
|
|
[ 'g', [ a ] ],
|
|
[ 'e', [ a ] ]
|
|
];
|
|
}
|
|
}
|
|
];
|
|
|
|
for ( let i = 0; i < cases.length; i++ ) {
|
|
ve.test.utils.runUrlStringHandlerTest( assert, cases[ i ].pasteString, cases[ i ].pasteHtml, cases[ i ].pasteType, cases[ i ].expectedData, cases[ i ].msg );
|
|
}
|
|
} );
|