mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-27 17:00:37 +00:00
Add test to cover mw.popups.setupTriggers
Follow up Id173b21. Bug: T133020 Change-Id: Id97cc7c7cb546d09c196dab8377e9e61a0b12f85
This commit is contained in:
parent
28af47b231
commit
91d3b510cb
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue