( function ( M ) { var pageIssues = M.require( 'skins.minerva.scripts/pageIssues' ), util = M.require( 'mobile.startup/util' ), extractMessage = pageIssues.test.extractMessage, createBanner = pageIssues.test.createBanner, icon = {}, formatPageIssuesSeverity = pageIssues.test.formatPageIssuesSeverity, MEDIUM_ISSUE = { issue: { severity: 'MEDIUM', icon: icon }, iconString: 'i', text: 't' }, MEDIUM_MULTIPLE_ISSUE = { issue: { severity: 'MEDIUM', grouped: true, icon: icon }, iconString: 'i', text: 't' }, LOW_MULTIPLE_ISSUE = { issue: { severity: 'LOW', grouped: true, icon: icon }, iconString: 'i', text: 't' }, LOW_ISSUE = { issue: { severity: 'LOW', icon: icon }, iconString: 'i', text: 't' }, HIGH_ISSUE = { issue: { severity: 'HIGH', icon: icon }, iconString: 'i', text: 't' }, getAllIssuesSections = pageIssues.test.getAllIssuesSections, OverlayManager = M.require( 'mobile.startup/OverlayManager' ), Page = M.require( 'mobile.startup/Page' ), overlayManager = new OverlayManager( require( 'mediawiki.router' ) ), $mockContainer = $( '
ambox text span |
Smelly
' }, 'When the box is a child of mw-collapsible-content it grouped' ], [ $( '' ).html( 'Dirty
' }, 'When the box is not child of mw-collapsible-content it !grouped' ] ].forEach( function ( test ) { sinon.assert.match( // eslint-disable-line no-undef extractMessage( test[ 0 ] ), test[ 1 ], test[ 2 ] ); } ); } ); QUnit.test( 'getAllIssuesSections', function ( assert ) { var multipleIssuesWithDeletion, multipleIssues, allIssuesOldTreatment, allIssuesNewTreatment; allIssuesOldTreatment = { 0: [ MEDIUM_ISSUE, LOW_ISSUE, MEDIUM_ISSUE ] }; multipleIssues = { 0: [ util.extend( {}, MEDIUM_ISSUE, { grouped: true } ), util.extend( {}, LOW_ISSUE, { grouped: true } ), util.extend( {}, MEDIUM_ISSUE, { grouped: true } ) ] }; multipleIssuesWithDeletion = { 0: [ HIGH_ISSUE, util.extend( {}, MEDIUM_ISSUE, { grouped: true } ), util.extend( {}, LOW_ISSUE, { grouped: true } ), util.extend( {}, MEDIUM_ISSUE, { grouped: true } ) ] }; allIssuesNewTreatment = { 0: [ HIGH_ISSUE, LOW_ISSUE, MEDIUM_ISSUE ], 1: [ MEDIUM_ISSUE ] }; assert.deepEqual( getAllIssuesSections( allIssuesOldTreatment ), [ '0', '0', '0' ], 'section numbers correctly extracted from old treatment' ); assert.deepEqual( getAllIssuesSections( allIssuesNewTreatment ), [ '0', '0', '0', '1' ], 'section numbers correctly extracted from new treatment' ); assert.deepEqual( getAllIssuesSections( multipleIssues ), [ '0' ], 'multiple issues are packed into one entry since there is one box' ); assert.deepEqual( getAllIssuesSections( multipleIssuesWithDeletion ), [ '0', '0' ], 'while multiple issues are grouped, non-multiple issues are still reported' ); } ); }( mw.mobileFrontend ) );