mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-22 11:02:58 +00:00
6cbedbf9d2
* Remove need for manual hacking of sub groups via "msg" strings carefully prepended to every assertion. * Improve CI details, by reporting the specific case that failed, and local dev via ability to re-run each case, and reporting names directly in the HTML Reporter and CLI summary. * Reduce need for assert.async() and tracking of callbacks, especially to improve failure details in case of Promise rejection. Current logic was likely to cause a confusing timeout instead of a clear failure if the promise ends up rejected. QUnit propagates these as part of awaiting and asserting the test closure's promise value (as async fn) automatically. This approach also avoids the pitfal of a falsely passing test when an assertion inside a done() handler was never reached. * Use modern for-of where possible to remove need for closures and arrow functions. Thus reducing complexity of test code, where complexity should be kept lowest to avoid false confidence. * Use plain for-in instead of overly complex Object.keys().forEach(). Change-Id: I934a266e75e64371081f104cfb867fb2c282c84a
35 lines
984 B
JavaScript
35 lines
984 B
JavaScript
/*!
|
|
* VisualEditor UserInterface UrlStringTransferHandler tests.
|
|
*
|
|
* @copyright See AUTHORS.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ui.UrlStringTransferHandler (MW)' );
|
|
|
|
/* Tests */
|
|
|
|
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 );
|
|
} );
|