2015-08-23 16:40:22 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface UrlStringTransferHandler tests.
|
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org
|
2015-08-23 16:40:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
QUnit.module( 've.ui.UrlStringTransferHandler (MW)' );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
|
|
|
QUnit.test( 'paste', function ( assert ) {
|
|
|
|
var i,
|
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
msg: 'External link converts to internal link',
|
|
|
|
pasteString: location.origin + mw.Title.newFromText( 'Main Page' ).getUrl(),
|
|
|
|
pasteType: 'text/plain',
|
|
|
|
expectedData: function () {
|
|
|
|
// Explicitly create an internal link so we can assert this behaviour is working
|
2018-09-03 21:11:29 +00:00
|
|
|
var 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 ] ]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2017-05-08 21:45:28 +00:00
|
|
|
ve.test.utils.runUrlStringHandlerTest( assert, cases[ i ].pasteString, cases[ i ].pasteHtml, cases[ i ].pasteType, cases[ i ].expectedData, cases[ i ].msg );
|
2015-08-23 16:40:22 +00:00
|
|
|
}
|
|
|
|
} );
|