mediawiki-extensions-Visual.../modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
James D. Forrester 2c77e88d2c doc: Bump copyright year for 2020
Change-Id: I30539877543dc2a57bd1428a00d10ac46d8fc294
2020-01-08 09:13:24 -08:00

40 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', 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
var 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 ( 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 );
}
} );