mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-25 04:23:33 +00:00
e382d3af0a
Change-Id: Ica8773f54572bd90d4ee1ecde43254331fd2e313
39 lines
1 KiB
JavaScript
39 lines
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 ] ]
|
|
];
|
|
}
|
|
}
|
|
];
|
|
|
|
cases.forEach( ( caseItem ) => {
|
|
ve.test.utils.runUrlStringHandlerTest( assert, caseItem.pasteString, caseItem.pasteHtml, caseItem.pasteType, caseItem.expectedData, location.origin, caseItem.msg );
|
|
} );
|
|
} );
|