2018-07-30 14:35:54 +00:00
|
|
|
( function ( M ) {
|
2018-08-16 19:00:38 +00:00
|
|
|
var createBanner = M.require( 'skins.minerva.scripts/pageIssues' ).test.createBanner,
|
2018-07-30 14:35:54 +00:00
|
|
|
OverlayManager = M.require( 'mobile.startup/OverlayManager' ),
|
2018-07-26 10:13:33 +00:00
|
|
|
Page = M.require( 'mobile.startup/Page' ),
|
2018-07-30 14:35:54 +00:00
|
|
|
overlayManager = new OverlayManager( require( 'mediawiki.router' ) ),
|
|
|
|
$mockContainer = $(
|
|
|
|
'<div id=\'bodyContent\'>' +
|
|
|
|
'<table class=\'ambox ambox-content\'>' +
|
|
|
|
'<tbody class=\'mbox-text\'>' +
|
|
|
|
'<tr><td><span class=\'mbox-text-span\'> ambox text span </span></td></tr>' +
|
|
|
|
'</tbody>' +
|
|
|
|
'</table>' +
|
|
|
|
'</div>'
|
|
|
|
),
|
|
|
|
labelText = 'label text',
|
|
|
|
inline = true,
|
2018-07-26 10:13:33 +00:00
|
|
|
processedAmbox = createBanner(
|
|
|
|
new Page( { el: $mockContainer } ),
|
2018-08-23 20:57:47 +00:00
|
|
|
labelText, '0', inline, overlayManager
|
2018-07-26 10:13:33 +00:00
|
|
|
);
|
2018-07-30 14:35:54 +00:00
|
|
|
|
|
|
|
QUnit.module( 'Minerva cleanuptemplates' );
|
|
|
|
|
|
|
|
QUnit.test( 'createBanner() should add a "learn more" message', function ( assert ) {
|
|
|
|
assert.strictEqual( /⧼skin-minerva-issue-learn-more⧽/.test( processedAmbox.html() ), true );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'createBanner() should add an icon', function ( assert ) {
|
|
|
|
assert.strictEqual( /mw-ui-icon/.test( processedAmbox.html() ), true );
|
|
|
|
} );
|
|
|
|
QUnit.test( 'clicking on the product of createBanner() should trigger a URL change', function ( assert ) {
|
|
|
|
processedAmbox.click();
|
|
|
|
assert.strictEqual( window.location.hash, '#/issues/0' );
|
|
|
|
} );
|
|
|
|
|
2018-07-11 15:16:21 +00:00
|
|
|
// NOTE: Only for PageIssues AB
|
|
|
|
QUnit.test( 'clicking on the product of createBanner() should trigger a custom event', function ( assert ) {
|
|
|
|
var mockAction = {
|
|
|
|
action: 'issueClicked',
|
|
|
|
issueSeverity: [ 'MEDIUM' ]
|
|
|
|
};
|
|
|
|
mw.trackSubscribe( 'minerva.PageIssuesAB', function ( topic, data ) {
|
|
|
|
assert.equal( JSON.toString( mockAction ), JSON.toString( data ) );
|
|
|
|
} );
|
|
|
|
} );
|
2018-07-30 14:35:54 +00:00
|
|
|
}( mw.mobileFrontend ) );
|