' ).appendTo( $qf ) );
scroller.empty();
assert.ok( !scroller.$dragIcon.hasClass( 'pointing-down' ), 'We successfully reset the chevron' );
assert.ok( !scroller.$container.hasClass( 'invite' ), 'We successfully reset the invite' );
} );
QUnit.test( 'Metadata div is only animated once', 5, function ( assert ) {
var $qf = $( '#qunit-fixture' ),
displayCount,
scroller = new mw.mmv.ui.MetadataPanelScroller( $qf, $( '
' ).appendTo( $qf ), {
// We simulate localStorage to avoid test side-effects
getItem: function () { return displayCount; },
setItem: function ( _, val ) { displayCount = val; }
} );
scroller.attach();
scroller.animateMetadataOnce();
assert.ok( scroller.hasAnimatedMetadata,
'The first call to animateMetadataOnce set hasAnimatedMetadata to true' );
assert.ok( $qf.hasClass( 'invite' ),
'The first call to animateMetadataOnce led to an animation' );
$qf.removeClass( 'invite' );
scroller.animateMetadataOnce();
assert.strictEqual( scroller.hasAnimatedMetadata, true, 'The second call to animateMetadataOnce did not change the value of hasAnimatedMetadata' );
assert.ok( !$qf.hasClass( 'invite' ),
'The second call to animateMetadataOnce did not lead to an animation' );
scroller.unattach();
scroller.attach();
scroller.animateMetadataOnce();
assert.ok( $qf.hasClass( 'invite' ),
'After closing and opening the viewer, the panel is animated again' );
} );
QUnit.test( 'No localStorage', 1, function( assert ) {
var $qf = $( '#qunit-fixture' ),
scroller = new mw.mmv.ui.MetadataPanelScroller( $qf, $( '
' ).appendTo( $qf ) );
this.sandbox.stub( $, 'scrollTo', function() { return { scrollTop : function() { return 10; } }; } );
scroller.scroll();
assert.ok( !scroller.savedHasOpenedMetadata, 'No localStorage, we don\'t try to save the opened flag' );
} );
QUnit.test( 'localStorage is full', 1, function( assert ) {
var $qf = $( '#qunit-fixture' ),
scroller = new mw.mmv.ui.MetadataPanelScroller( $qf, $( '
' ).appendTo( $qf ),
{ getItem : $.noop, setItem : function() { throw 'I am full'; } } );
this.sandbox.stub( $, 'scrollTo', function() { return { scrollTop : function() { return 10; } }; } );
scroller.scroll();
assert.ok( scroller.savedHasOpenedMetadata, 'Full localStorage, we don\'t try to save the opened flag more than once' );
} );
}( mediaWiki, jQuery ) );