2020-11-18 09:11:12 +00:00
|
|
|
QUnit.module( 'ext.RevisionSlider.HelpDialog' );
|
2016-06-29 10:43:46 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
QUnit.test( 'Initialize HelpDialog', function ( assert ) {
|
2023-06-22 09:41:37 +00:00
|
|
|
const HelpDialog = require( 'ext.RevisionSlider.Slider' ).HelpDialog;
|
|
|
|
const helpDialog = new HelpDialog(),
|
2020-11-18 09:11:12 +00:00
|
|
|
windowManager = new OO.ui.WindowManager();
|
2016-07-01 10:24:30 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
function getSlideTextHtml( slide ) {
|
|
|
|
return slide.$element.find( '.mw-revslider-help-dialog-text' ).html();
|
|
|
|
}
|
2016-06-29 10:43:46 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
function addLinkTargets( parsedMessage ) {
|
2023-06-22 09:41:37 +00:00
|
|
|
const $container = $( '<div>' ).html( parsedMessage );
|
2020-11-18 09:11:12 +00:00
|
|
|
$container.find( 'a' ).attr( 'target', '_blank' );
|
|
|
|
return $container.html();
|
|
|
|
}
|
2016-07-20 09:59:03 +00:00
|
|
|
|
2023-04-21 07:03:07 +00:00
|
|
|
$( document.body ).append( windowManager.$element );
|
2020-11-18 09:11:12 +00:00
|
|
|
windowManager.addWindows( [ helpDialog ] );
|
2016-06-29 10:43:46 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
assert.strictEqual( helpDialog.slides.length, 4 );
|
|
|
|
assert.strictEqual( helpDialog.slidePointer, 0 );
|
|
|
|
assert.strictEqual(
|
|
|
|
getSlideTextHtml( helpDialog.slides[ 0 ] ),
|
|
|
|
addLinkTargets( mw.message( 'revisionslider-help-dialog-slide1' ).parse() )
|
|
|
|
);
|
|
|
|
assert.strictEqual(
|
|
|
|
getSlideTextHtml( helpDialog.slides[ 1 ] ),
|
|
|
|
addLinkTargets( mw.message( 'revisionslider-help-dialog-slide2' ).parse() )
|
|
|
|
);
|
|
|
|
assert.strictEqual(
|
|
|
|
getSlideTextHtml( helpDialog.slides[ 2 ] ),
|
|
|
|
addLinkTargets( mw.message( 'revisionslider-help-dialog-slide3a' ).parse() )
|
|
|
|
);
|
|
|
|
assert.strictEqual(
|
|
|
|
getSlideTextHtml( helpDialog.slides[ 3 ] ),
|
|
|
|
addLinkTargets( mw.message( 'revisionslider-help-dialog-slide4' ).parse() )
|
|
|
|
);
|
|
|
|
} );
|