MinervaNeue/tests/qunit/skins.minerva.scripts/test_PageIssuesOverlay.js
Jan Drewniak 1a9bcd1e8a page-issues sectionNumbers consistency on modalClose event
For the page-issues modalClose event, the number of values for `sectionNumbers`
and `issuesSeverity` should be the same, since `sectionNumbers` should describe
the the section of each visible issue in the modal, not the section of the
modal itself.

Bug: T203050
Change-Id: Ic58c5940a6059e71aa3aeed26232afbe8faf1618
2018-09-05 21:29:53 +02:00

58 lines
1.4 KiB
JavaScript

( function ( M ) {
var PageIssuesOverlay = M.require( 'skins.minerva.scripts/PageIssuesOverlay' );
QUnit.module( 'Minerva PageIssuesOverlay', {
setup: function () {
this.logger = {
log: this.sandbox.spy()
};
}
} );
QUnit.test( '#log (section=all)', function ( assert ) {
var overlay = new PageIssuesOverlay( [], this.logger, 'all', 0 );
overlay.onExit();
assert.strictEqual( this.logger.log.calledOnce, true, 'Logger called once' );
assert.strictEqual(
this.logger.log.calledWith( {
action: 'modalClose',
issuesSeverity: []
} ), true, 'sectionNumbers is not set (T202940)'
);
} );
QUnit.test( '#log (section=1)', function ( assert ) {
var overlay = new PageIssuesOverlay( [
{
severity: 'MEDIUM'
}
], this.logger, '1', 0 );
overlay.onExit();
assert.strictEqual(
this.logger.log.calledWith( {
action: 'modalClose',
issuesSeverity: [ 'MEDIUM' ],
sectionNumbers: [ '1' ]
} ), true, 'sectionNumbers is set'
);
} );
QUnit.test( '#log (section=2) multiple issues', function ( assert ) {
var overlay = new PageIssuesOverlay(
[ {
severity: 'MEDIUM'
},
{
severity: 'LOW'
} ], this.logger, '2', 0 );
overlay.onExit();
assert.strictEqual(
this.logger.log.calledWith( {
action: 'modalClose',
issuesSeverity: [ 'MEDIUM', 'LOW' ],
sectionNumbers: [ '2', '2' ]
} ), true, 'sectionNumbers is set for each issue'
);
} );
}( mw.mobileFrontend ) );