2015-08-23 16:40:22 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface UrlStringTransferHandler tests.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2015-08-23 16:40:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
QUnit.module( 've.ui.UrlStringTransferHandler (MW)' );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2021-04-30 09:33:22 +00:00
|
|
|
QUnit.test( 'paste', ( assert ) => {
|
2021-04-29 14:42:18 +00:00
|
|
|
const cases = [
|
2015-08-23 16:40:22 +00:00
|
|
|
{
|
|
|
|
msg: 'External link converts to internal link',
|
|
|
|
pasteString: location.origin + mw.Title.newFromText( 'Main Page' ).getUrl(),
|
|
|
|
pasteType: 'text/plain',
|
2021-04-30 09:33:22 +00:00
|
|
|
expectedData: () => {
|
2015-08-23 16:40:22 +00:00
|
|
|
// Explicitly create an internal link so we can assert this behaviour is working
|
2021-04-29 14:42:18 +00:00
|
|
|
const a = ve.dm.MWInternalLinkAnnotation.static.newFromTitle( mw.Title.newFromText( 'Main Page' ) ).element;
|
2015-08-23 16:40:22 +00:00
|
|
|
return [
|
|
|
|
[ 'M', [ a ] ],
|
|
|
|
[ 'a', [ a ] ],
|
|
|
|
[ 'i', [ a ] ],
|
|
|
|
[ 'n', [ a ] ],
|
|
|
|
[ ' ', [ a ] ],
|
|
|
|
[ 'P', [ a ] ],
|
|
|
|
[ 'a', [ a ] ],
|
|
|
|
[ 'g', [ a ] ],
|
|
|
|
[ 'e', [ a ] ]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-05-01 13:02:29 +00:00
|
|
|
cases.forEach( ( caseItem ) => {
|
|
|
|
ve.test.utils.runUrlStringHandlerTest( assert, caseItem.pasteString, caseItem.pasteHtml, caseItem.pasteType, caseItem.expectedData, location.origin, caseItem.msg );
|
|
|
|
} );
|
2015-08-23 16:40:22 +00:00
|
|
|
} );
|