Add test to cover mw.popups.setupTriggers

Follow up Id173b21.

Bug: T133020
Change-Id: Id97cc7c7cb546d09c196dab8377e9e61a0b12f85
This commit is contained in:
Sam Smith 2016-04-22 10:55:01 +01:00 committed by Phuedx
parent 28af47b231
commit 91d3b510cb

View file

@ -129,4 +129,36 @@
mw.popups.$content = $originalContent;
} );
QUnit.test( 'setupTriggers', function ( assert ) {
var $link = $( '<a>', {
text: 'Popups',
title: 'Popups',
href: '#'
} ).appendTo( 'body' ),
originalScrolled = mw.popups.scrolled,
renderSpy = this.sandbox.stub( mw.popups.render, 'render', $.noop ),
$renderedElement;
assert.expect( 1 );
mw.popups.setupTriggers( $link );
mw.popups.scrolled = false;
$link.trigger( 'mouseenter' );
$renderedElement = renderSpy.firstCall.args[ 0 ];
assert.strictEqual(
// Compare the underlying element rather than (likely) differing instances of the jQuery
// class.
$renderedElement.get( 0 ),
$link.get( 0 ),
'When the "mouseenter" event fires then the underlying element is passed to the renderer.'
);
// Restore original state.
mw.popups.scrolled = originalScrolled;
$link.remove();
} );
} )( jQuery, mediaWiki );