mediawiki-skins-MinervaNeue/tests/qunit/skins.minerva.scripts/test_pageIssues.js
Jan Drewniak ae19031f8e Log sectionNumbers in PageIssues schema
Adds logging for the sectionNumbers field in the PageIssues schema.

Additional changes:
* createBanner now requires section number to be a string - this ensures
consistency with how these are used.
* fix a bug which meant createBanner was being called with undefined
section number (due to table of contents)
* Fix some indents in some JSDoc blocks
* Change parameter in function signature from mixed type (int or string)
to explicit string
* update schema number

Depends-On: Ia2696b86c6855d7b46a3f668585377d106d7af23
Bug: T202098
Change-Id: I20511a77258ea245f3d6fe93ade238e5df397a71
2018-08-27 18:02:51 +00:00

47 lines
1.7 KiB
JavaScript

( function ( M ) {
var createBanner = M.require( 'skins.minerva.scripts/pageIssues' ).test.createBanner,
OverlayManager = M.require( 'mobile.startup/OverlayManager' ),
Page = M.require( 'mobile.startup/Page' ),
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,
processedAmbox = createBanner(
new Page( { el: $mockContainer } ),
labelText, '0', inline, overlayManager
);
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' );
} );
// 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 ) );
} );
} );
}( mw.mobileFrontend ) );