mediawiki-extensions-Visual.../modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
Ed Sanders d42a0772bb Move verbose copyright message to AUTHORS.txt
Avoids having to update the date in every file every year,
which we stopped doing.

Change-Id: I7bf7aa0937eef911e00772470091753a7b06fd3d
2023-12-01 16:07:39 +00:00

39 lines
1.1 KiB
JavaScript

/*!
* VisualEditor UserInterface UrlStringTransferHandler tests.
*
* @copyright See AUTHORS.txt
*/
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, location.origin, cases[ i ].msg );
}
} );