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 */
|
|
|
|
|
2024-05-01 17:25:33 +00:00
|
|
|
QUnit.test.each( 'paste', [
|
|
|
|
{
|
|
|
|
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 ] ]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
], ( assert, 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
|
|
|
} );
|