mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-13 22:49:46 +00:00
5a65bd5200
* Declare variables inline, as per the current code conventions. * Use built-in assert.true() and assert.false() in a few places. * Use built-in QUnit.test.each() to remove need for ad-hoc loops and inline composing of assertion messages with common prefixes. This also creates clearer and more detailed test reports, and more granular ability to re-run specific test cases. * Remove unneeded use of `QUnit.newMwEnvironment()`. * Simplify restoring of mw.Uri by storing the original reference once outside the test, and then re-using that each time. * Use mw.config.set() for improved familiarity and rely on natural restoration instead of the extra 'config' key abstraction which is another thing to learn and understand. Change-Id: I796e034854203d2e0e78e510458f4b34603e9901
40 lines
1.4 KiB
JavaScript
40 lines
1.4 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 ) {
|
|
assert.true( /mw-ui-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 ) );
|