mediawiki-skins-MinervaNeue/tests/qunit/skins.minerva.scripts/page-issues/index.test.js
Jdlrobson 2ee3e27406 Revert "Drop mw.mobileFrontend references"
This reverts commit 19ea6328b0.

Reason for revert: Breaks page issues and image overlay. I
will break this up into smaller less risky patches.

Change-Id: If5b76245bf60bfa9cf977cdbf37ee0d6bb65f9d9
2023-11-03 19:26:16 +00:00

41 lines
1.5 KiB
JavaScript

( function ( M ) {
var
mobile = M.require( 'mobile.startup' ),
pageIssues = require( '../../../../resources/skins.minerva.scripts/page-issues/index.js' ),
insertBannersOrNotice = pageIssues.test.insertBannersOrNotice,
OverlayManager = mobile.OverlayManager,
PageHTMLParser = mobile.PageHTMLParser,
overlayManager = OverlayManager.getSingleton(),
$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,
SECTION = '0',
processedAmbox = insertBannersOrNotice(
new PageHTMLParser( $mockContainer ),
labelText, SECTION, inline, overlayManager
).ambox;
QUnit.module( 'Minerva pageIssues' );
QUnit.test( 'insertBannersOrNotice() should add a "learn more" message', function ( assert ) {
assert.true( /⧼skin-minerva-issue-learn-more⧽/.test( processedAmbox.html() ) );
} );
QUnit.test( 'insertBannersOrNotice() should add an icon', function ( assert ) {
// FIXME: Remove mw-ui-icon when T346184 and/or T346162 has been resolved.
assert.true( /(mw-ui-icon|mf-icon)/.test( processedAmbox.html() ) );
} );
QUnit.test( 'clicking on the product of insertBannersOrNotice() should trigger a URL change', function ( assert ) {
processedAmbox.click();
assert.strictEqual( window.location.hash, '#/issues/' + SECTION );
} );
}( mw.mobileFrontend ) );