mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-27 23:50:30 +00:00
Fix broken QUnit test
Correct some options names and make minor adjustments to the constructor function Bug: T181348 Change-Id: Ia9fe9d2923b895d3dc530280e3987e27c88d3282
This commit is contained in:
parent
94fc4bbe13
commit
89909ccf53
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
function NotificationBadge( options ) {
|
||||
var $el,
|
||||
count = 0,
|
||||
count = options.notificationCountRaw || 0,
|
||||
el = options.el;
|
||||
|
||||
if ( el ) {
|
||||
|
@ -26,7 +26,7 @@
|
|||
count = Number( $el.find( 'span' ).data( 'notification-count' ) );
|
||||
}
|
||||
View.call( this, options );
|
||||
this.url = this.$el.find( 'a' ).attr( 'href' );
|
||||
this.url = options.url;
|
||||
this._bindOverlayManager();
|
||||
this.setCount( count );
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
overlayManager: this.OverlayManager,
|
||||
hasNotifications: true,
|
||||
hasUnseenNotifications: true,
|
||||
notificationCountRawRaw: 5
|
||||
notificationCountRaw: 5
|
||||
} );
|
||||
initialClassExpectationsMet = badge.$el.find( '.mw-ui-icon' ).length === 0 &&
|
||||
badge.$el.find( '.zero' ).length === 0;
|
||||
|
@ -24,27 +24,27 @@
|
|||
assert.ok( initialClassExpectationsMet, 'No icon and no zero class' );
|
||||
assert.ok( badge.$el.find( '.zero' ).length === 1, 'A zero class is present on the badge' );
|
||||
badge.setCount( 105 );
|
||||
assert.ok( badge.options.notificationCountRawRaw, 100,
|
||||
assert.ok( badge.options.notificationCountRaw, 100,
|
||||
'Number is capped to 100.' );
|
||||
} );
|
||||
|
||||
QUnit.test( '#setCount (Eastern Arabic numerals)', function ( assert ) {
|
||||
var badge = new NotificationBadge( {
|
||||
overlayManager: this.OverlayManager,
|
||||
el: $( '<div><a title="n" href="/" class="notification-unseen"><div class="circle"><span>۲</span></div></a></div>' )
|
||||
el: $( '<div><a title="n" href="/" class="notification-unseen"><div class="circle" ><span data-notification-count="2">۲</span></div></a></div>' )
|
||||
} );
|
||||
assert.ok( badge.options.notificationCountRawRaw, 2,
|
||||
assert.ok( badge.options.notificationCountRaw, 2,
|
||||
'Number is parsed from Eastern Arabic numerals' );
|
||||
assert.ok( badge.options.notificationCountRawRawString, '۲',
|
||||
assert.ok( badge.options.notificationCountString, '۲',
|
||||
'Number will be rendered in Eastern Arabic numerals' );
|
||||
badge.setCount( 5 );
|
||||
assert.ok( badge.options.notificationCountRawRawString, '۵',
|
||||
assert.ok( badge.options.notificationCountString, '۵',
|
||||
'Number will be rendered in Eastern Arabic numerals' );
|
||||
} );
|
||||
|
||||
QUnit.test( '#render [hasUnseenNotifications]', function ( assert ) {
|
||||
var badge = new NotificationBadge( {
|
||||
notificationCountRawRaw: 0,
|
||||
notificationCountRaw: 0,
|
||||
overlayManager: this.OverlayManager,
|
||||
hasNotifications: false,
|
||||
hasUnseenNotifications: false
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
QUnit.test( '#markAsSeen', function ( assert ) {
|
||||
var badge = new NotificationBadge( {
|
||||
notificationCountRawRaw: 2,
|
||||
notificationCountRaw: 2,
|
||||
overlayManager: this.OverlayManager,
|
||||
hasNotifications: true,
|
||||
hasUnseenNotifications: true
|
||||
|
|
Loading…
Reference in a new issue