mediawiki-skins-MinervaNeue/tests/qunit/skins.minerva.scripts/page-issues/index.test.js
Jdlrobson ca28efc9c7 Drop mw.mobileFrontend references
This restores the previously reverted patchset
If5b76245bf60bfa9cf977cdbf37ee0d6bb65f9d9

Changes since original:
* Added Depends-On to MobileFrontend
* Uses OOUI classes for page issues rather than es6 classes - ES6
classes do not support modifications to class prior to running
super so MobileFrontend's View class is not compatible without
significant refactors.

Depends-On: I24ad75adf8519102ca356d64d99d765ab69180cc
Bug: T348807
Change-Id: I4ff82af0251254c846f2caee330af5af738f6029
2023-11-10 01:30:52 +00:00

39 lines
1.4 KiB
JavaScript

( function () {
const
mobile = require( 'mobile.startup' ),
pageIssues = require( '../../../../resources/skins.minerva.scripts/page-issues/index.js' ),
insertBannersOrNotice = pageIssues.test.insertBannersOrNotice,
PageHTMLParser = mobile.PageHTMLParser,
overlayManager = mobile.getOverlayManager(),
$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 ) {
assert.true( /(minerva-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 );
} );
}() );